Compare commits
No commits in common. "f04d3d86eab8807861fc6058cc460a523fc767f4" and "940bf1a32c4c297a6838192ff4268ab5459713b7" have entirely different histories.
f04d3d86ea
...
940bf1a32c
4
.gitignore
vendored
4
.gitignore
vendored
@ -54,10 +54,10 @@ dkms.conf
|
||||
|
||||
#Bin
|
||||
bin/*
|
||||
tmp/*
|
||||
client_test/*
|
||||
server_test/*
|
||||
|
||||
p-client
|
||||
p-server
|
||||
server
|
||||
client
|
||||
slowclient
|
11
Makefile
11
Makefile
@ -23,13 +23,14 @@ p-mulclient: socket_wrapper.o p-client.c
|
||||
slowclient: socket_wrapper.o client.c
|
||||
$(CC) -o slowclient client.c socket_wrapper.o $(CFLAGS) -D SLOW_CLIENT=1000
|
||||
|
||||
.PHONY: clean test
|
||||
.PHONY: clean moveall
|
||||
clean:
|
||||
rm *.o $(Bin)
|
||||
rm $(addprefix client_test/,$(ClientBin))
|
||||
rm $(addprefix server_test/,$(ServerBin))
|
||||
|
||||
test:
|
||||
make all
|
||||
make slowclient
|
||||
./test.sh
|
||||
moveall:
|
||||
mv client client_test/client
|
||||
mv p-client client_test/p-client
|
||||
mv server server_test/server
|
||||
mv p-server server_test/p-server
|
@ -16,7 +16,7 @@ Server OPTION and arguments:
|
||||
|
||||
Client option and arguments:
|
||||
- `-b` or `--benchmark` :benchmark mode
|
||||
- `-nv` or `--no-verbose` :no progress bar
|
||||
- `--nogui` :no progress bar
|
||||
|
||||
Available macro:
|
||||
|
||||
|
28
client.c
28
client.c
@ -133,7 +133,6 @@ int recvFile(int sock, const char * filename,size_t file_size){
|
||||
DisplayProgressBar100Percent(file_size);
|
||||
END:
|
||||
free(buf);
|
||||
close(fd);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
@ -199,9 +198,6 @@ static inline struct timespec timespec_sub(struct timespec a,struct timespec b){
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char filename_buf[1024];
|
||||
static bool stdinisatty;
|
||||
|
||||
int main(int argc, const char *argv[]){
|
||||
struct sockaddr_in addr;
|
||||
const char * filename;
|
||||
@ -211,26 +207,27 @@ int main(int argc, const char *argv[]){
|
||||
int sock, err;
|
||||
int retval = 0;
|
||||
init_bench_data();
|
||||
stdinisatty = isatty(STDIN_FILENO);
|
||||
|
||||
if (argc < (stdinisatty ? 4 : 3)){
|
||||
|
||||
if (argc < 4){
|
||||
fprintf(stderr,"USAUE: %s SERVERNAME PORT [Option]... [FILENAME]...\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
server_name = argv[1];
|
||||
server_port = atoi(argv[2]);
|
||||
while(arg_filename_start < argc){
|
||||
for(;;){
|
||||
if (strcmp("-b",argv[arg_filename_start])==0
|
||||
||strcmp("--benchmark",argv[arg_filename_start])==0){
|
||||
arg_filename_start++;
|
||||
bench.benchmode = true;
|
||||
}
|
||||
else if(strcmp("-nv",argv[arg_filename_start]) == 0||strcmp("--no-verbose",argv[arg_filename_start])==0){
|
||||
else if(strcmp("--nogui",argv[arg_filename_start])==0){
|
||||
arg_filename_start++;
|
||||
DisplayProgress = false;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
if (server_port == 0){
|
||||
fprintf(stderr,"port invalid\n");
|
||||
return 1;
|
||||
@ -254,19 +251,8 @@ int main(int argc, const char *argv[]){
|
||||
if (bench.benchmode){
|
||||
clock_gettime(bench.clock_id,&bench.begin);
|
||||
}
|
||||
for (;;){
|
||||
if (stdinisatty){
|
||||
if (arg_filename_start >= argc) break;
|
||||
while (arg_filename_start < argc){
|
||||
filename = argv[arg_filename_start++];
|
||||
}
|
||||
else{
|
||||
//unsafe.
|
||||
int t = fscanf(stdin,"%s",filename_buf);
|
||||
if (t != 1) break;
|
||||
filename = filename_buf;
|
||||
}
|
||||
fprintf(stdout,"request %s\n",filename);
|
||||
|
||||
sock = socket(AF_INET,SOCK_STREAM,0);
|
||||
if(sock < 0){
|
||||
perror("sock create fail");
|
||||
@ -292,7 +278,7 @@ int main(int argc, const char *argv[]){
|
||||
if (result.tv_sec == 0) avg = result.tv_nsec;
|
||||
else avg = result.tv_sec * 1e9 + result.tv_nsec;
|
||||
avg /= bench.op_count;
|
||||
fprintf(stdout,"operation: %lf us/op\n",avg / 1000.0);
|
||||
fprintf(stdout,"operation: %lf ns/op\n",avg);
|
||||
fprintf(stdout,"resolution: %ld sec %ld ns\n",bench.resolution.tv_sec,bench.resolution.tv_nsec);
|
||||
}
|
||||
|
||||
|
45
test.sh
45
test.sh
@ -1,45 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
function do_test(){
|
||||
local testname=$1
|
||||
if [ $? -eq 0 ];then
|
||||
echo -e "${testname} test \e[92m[success]\e[0m"
|
||||
else
|
||||
echo -e "${testname} test \e[91m[fail\e[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
cd testdata
|
||||
../server &
|
||||
server_pid=$!
|
||||
sleep 1
|
||||
cd ../tmp
|
||||
../client localhost 9091 test.txt
|
||||
do_test "normal"
|
||||
|
||||
../client localhost 9091 notexistfile.txt
|
||||
do_test "notexistfile"
|
||||
|
||||
echo test.txt | ../client localhost 9091
|
||||
do_test "pipeinput"
|
||||
|
||||
../slowclient localhost 9091 test.txt &
|
||||
process_id1=$!
|
||||
../p-client localhost 9091 test.txt &
|
||||
process_id2=$!
|
||||
../p-client localhost 9091 test.txt &
|
||||
process_id3=$!
|
||||
wait $process_id1
|
||||
return_code1=$?
|
||||
wait $process_id2
|
||||
return_code2=$?
|
||||
wait $process_id3
|
||||
return_code3=$?
|
||||
if [ $return_code1 -eq 0 -a $return_code2 -eq 0 -a $return_code3 -eq 0 ];then
|
||||
echo -e "multiconnection test \e[92m[success]\e[0m"
|
||||
else
|
||||
echo -e "multiconnection test \e[91m[fail\e[0m"
|
||||
fi
|
||||
rm *.txt
|
||||
echo turn off server :$server_pid
|
||||
kill $server_pid
|
1
testdata/list.txt
vendored
1
testdata/list.txt
vendored
@ -1 +0,0 @@
|
||||
test.txt
|
1
testdata/test.txt
vendored
1
testdata/test.txt
vendored
@ -1 +0,0 @@
|
||||
teststring
|
Loading…
Reference in New Issue
Block a user