-
Notifications
You must be signed in to change notification settings - Fork 20
/
assignment-1-test-iteration.sh
54 lines (38 loc) · 1.52 KB
/
assignment-1-test-iteration.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
. ./script-helpers
assignment_1_test_validation() {
filesdir=$1
numfiles=$2
writestr=$3
username=$4
./tester.sh ${numfiles} ${writestr}
if [ $? -ne 0 ]; then
add_validate_error "Expected zero success return from tester script"
fi
files_list=$(find ${filesdir} -name "${username}*.txt")
files_created=$(echo "${files_list}" | wc -l)
if [ ${files_created} -ne ${numfiles} ]; then
add_validate_error "expected ${numfiles} files created by ./tester.sh matching ${username}*.txt pattern within ${filesdir} but found ${files_created} with files list ${files_list}"
fi
./finder.sh
if [ $? -ne 1 ]; then
add_validate_error "finder.sh should have exited with return value 1 if no parameters were specified"
fi
./finder.sh /tmp
if [ $? -ne 1 ]; then
add_validate_error "finder.sh should have exited with return value 1 if search string was not specified"
fi
./finder.sh /non-exist-path "search"
if [ $? -ne 1 ]; then
add_validate_error "finder.sh should have exited with return value 1 if a non-existent path was specified"
fi
output=$(./finder.sh ${filesdir} ${writestr})
echo ${output} | grep "number of files are ${numfiles}"
if [ $? -ne 0 ]; then
add_validate_error "Expected to find number of files listed as ${numfiles} by finder script, found ${output}"
fi
echo ${output} | grep "number of matching lines are ${numfiles}"
if [ $? -ne 0 ]; then
add_validate_error "Expected to find number of matching lines listed as ${numfiles} by finder script, found ${output}"
fi
}