summaryrefslogtreecommitdiffstats
path: root/test.sh
blob: c4fbb5ea3a466e5af9d2a75f67c5f2c0554e22c5 (plain)
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
#! /bin/sh

FILE="test_file"
TMP="test_tmp"
KEY="secret_key_yeah_"	# 16 bytes for twofish
BIN="./cryptot"

if [ ! -x ${BIN} ]; then
	echo "" && exit 1;
fi;

# 80 Mb file
echo "generate a 70Mb file from source files."
if [ -f ${FILE} ]; then rm ${FILE}; fi;
if [ -f ${TMP} ]; then rm ${TMP}; fi;
cat *.c > ${FILE};
cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && \
cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && \
cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && \
cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} || exit 1;
echo "done."
rm ${TMP}

ARGS1="-v -c 1 -n 700 "
ARGS2="-v -x -c 1 -n 600 "
ARGSD="-d 127.0.0.1:4779"
ARGSS="-s 127.0.0.1:4779"

local(){

	cat ${FILE} | ${BIN} ${ARGS1} ${KEY} | ${BIN} -x ${ARGS2} ${KEY} > DEC
}

dist (){
	
	${BIN} -x ${ARGS2} ${ARGSS} ${KEY} > DEC & PID=$!
	sleep 2
	cat ${FILE} | ${BIN} ${ARGS1} ${ARGSD} ${KEY} || ( echo "error !!"; kill ${PID} exit 1 )
	wait ${PID}
}

local
echo "running cmp"
cmp ${FILE} DEC || echo "ERROR"
echo "OK."
rm DEC

dist
echo "running cmp"
cmp ${FILE} DEC || echo "ERROR"
echo "OK."

rm DEC ${FILE}