Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cd-ing to a long path #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions final-assignment-tests/shell/phase-1.tests
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
034
035
036
037
20 changes: 20 additions & 0 deletions final-assignment-tests/shell/test-037.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#/bin/bash

dir=long-path-123456
tmpdir=$(mktemp -d)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be prudent to check if the tmpdir is non-empty and exit 1 otherwise.


# PATH_MAX can be as low as 256, so were safe ${#dir} * 8 = 128
count=8

function test_input {
seq $count | while read i; do
echo -e "mkdir $dir; cd $dir"
done
echo "pwd"
}

n=$( cd $tmpdir; test_input | $MYSH | tr "/" "\n" | grep -c "^${dir}$" )
rm -rf $tmpdir

(( $n != $count )) && echo "Count expected $count, was $n" && exit 1
exit 0