-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·94 lines (77 loc) · 2.15 KB
/
test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# vous pouvez creer une hierarchie de fichier
# soit dans votre depots
# soit dans en script (et suppression en fin de test)
DATE='/bin/date'
rm -rf tmp
mkdir tmp
truthArray=(
""
"find DOSSIER"
"find DOSSIER -name fir.png"
"find DOSSIER -print"
"grep -r -l DOSSIER -e l"
"find DOSSIER -type f -exec file {} \; | grep image | cut -d : -f 1"
"find DOSSIER -exec ls -l -d {} \;"
"find DOSSIER -exec ls -l {} \;"
"find DOSSIER -exec ls -l \;"
"find DOSSIER -name fir.png -type f -exec file {} \; | grep image | cut -d : -f 1"
"find DOSSIER -print -exec ls -l {} \;"
#"find DOSSIER -name REGEXP"
#"grep -r -l DOSSIER -e REGEXP"
"./rsfind DOSSIER"
"./rsfind DOSSIER -i "
#"rsfind DOSSIER -t CHAINE"
)
testArray=(
""
"./rsfind DOSSIER"
"./rsfind DOSSIER --name fir.png"
"./rsfind DOSSIER --print"
"./rsfind DOSSIER -t l"
"./rsfind DOSSIER -i"
"./rsfind DOSSIER -l"
"./rsfind DOSSIER --exec \"ls -l {}\"" #
"./rsfind DOSSIER --exec \"ls -l\""
"./rsfind DOSSIER --name fir.png -i"
"./rsfind DOSSIER --print --exec \"ls -l {}\"" #
#"./rsfind DOSSIER --ename REGEXP"
#"./rsfind DOSSIER -T REGEXP = grep -r -l DOSSIER -e REGEXP"
"./rsfind DOSSIER -p 4"
"./rsfind DOSSIER -p 4 -i"
#"./rsfind DOSSIER -p 4 -t CHAINE"
)
test_error=false
for ((i = 0; i < ${#truthArray[@]}; i++))
do
echo "Test : ${testArray[$i]}"
#BEFORETRUTH=$($DATE +'%N')
eval ${truthArray[$i]} > tmp/truthTest.txt
#AFTERTRUTH=$($DATE +'%N')
#CMPTTRUTH=$(($AFTERTRUTH - $BEFORETRUTH))
#echo Truth exec is: $CMPTTRUTH
#BEFORETEST=$($DATE +'%N')
eval ${testArray[$i]} > tmp/resTest.txt
#AFTERTEST=$($DATE +'%N')
#CMPTTEST=$(($AFTERTEST - $BEFORETRUTH))
#echo Test exec is: $CMPTTEST
diff tmp/truthTest.txt tmp/resTest.txt
e_code=$?
if [ $e_code != 0 ]
then
printf "TEST FAIL : %d\n" "$e_code"
test_error=true
else
printf "TEST OK!\n"
fi
echo
echo ============================================
echo
done
rm -rf tmp
if [ $test_error = true ]
then
exit 2
else
exit 0
fi