-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
104 lines (70 loc) · 2.13 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
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
###
# Description: Test script for project: Files Transmission
# Author: Martin Kopec
# Login: xkopec42
# Date: 23.04.2016
###
#compile .cpp sources
make
#create direcotry with file to transport
if [ -d "testFolder" ]; then
rm -r testFolder
mkdir -p testFolder
if [ $? -ne 0 ]; then
echo "Testing terminated, because testFolder folder was not created, probably because of rights"
exit 1
fi
else
mkdir -p testFolder
if [ $? -ne 0 ]; then
echo "Testing terminated, because testFolder folder was not created, probably because of rights"
exit 1
fi
fi
echo "This is content of a file, which will be transferred" > ./testFolder/fileToTransport
echo "This is content of a file, which will be downloaded" > fileToDownload
#run server
./server -p 12241 &
TASK_PID=$!
echo "running server: $TASK_PID"
#run tests
echo "----TEST 01: Upload fileToTransport file from testFolder"
./client -p 12241 -h 127.0.0.1 -u ./testFolder/fileToTransport
echo "----TEST 01 completed"
echo "---------------------"
echo "----TEST 02: Download not existed file"
./client -p 12241 -h 127.0.0.1 -d notExistedFile123587
echo "----TEST 02 completed"
echo "---------------------"
#create folder for client, because server and client can't be in the same location, it would be make no sense
if [ -d "clientDir" ]; then
rm -r clientDir
mkdir -p clientDir
if [ $? -ne 0 ]; then
echo "Testing terminated, because testFolder folder was not created, probably because of rights"
exit 1
fi
else
mkdir -p clientDir
if [ $? -ne 0 ]; then
echo "Testing terminated, because testFolder folder was not created, probably because of rights"
exit 1
fi
fi
cp client ./clientDir/ #copy client to the folder
cd ./clientDir/
#run test
echo "----TEST 03: Download fileToDownload file"
./client -p 12241 -h 127.0.0.1 -d fileToDownload
echo "----TEST 03 completed"
echo "---------------------"
cd ../
#kill server process
kill $TASK_PID #>/dev/null
#clean all created files
make clean >/dev/null
rm -r testFolder
rm -r clientDir
rm fileToTransport
rm fileToDownload