bug fixes and test2
This commit is contained in:
14
Makefile
14
Makefile
@ -29,7 +29,7 @@ VPATH := $(SRC_DIR) $(wildcard $(LIB_DIR)/*)
|
||||
|
||||
|
||||
all: $(BUILD_DIR)/server $(BUILD_DIR)/client
|
||||
@echo "done!"
|
||||
@echo "Compiled!"
|
||||
|
||||
|
||||
# -SERVER-RULES-----------------------------------------------------------------
|
||||
@ -97,8 +97,14 @@ print-%: ; @echo $* = $($*)
|
||||
|
||||
# -TESTS------------------------------------------------------------------------
|
||||
|
||||
test1:
|
||||
@echo "[threadpool]\n\nquantity = 10\npending = 20\n\n[files]\n\nMaxFiles = 20\n\nMaxSize = 10000000\n\n[log]\n\nlogFile = ./logs/l.log\n\n[socket]\n\nname = ./socket\nbacklog = 100\n" > build/confix.txt
|
||||
test1: all
|
||||
@echo "[threadpool]\n\nquantity = 1\npending = 10\n\n[files]\n\nMaxFiles = 10000\nMaxSize = 128000\n\n[log]\n\nlogFile = ./logs/l.log\n\n[socket]\n\nname = ./socket\nbacklog = 100\n" > build/confix.txt
|
||||
valgrind --leak-check=full ./server &
|
||||
./scripts/test1.sh
|
||||
bash scripts/test1.sh
|
||||
pkill -1 memcheck-amd64
|
||||
|
||||
test2: all
|
||||
@echo "[threadpool]\n\nquantity = 4\npending = 100\n\n[files]\n\nMaxFiles = 10\nMaxSize = 1000\n\n[log]\n\nlogFile = ./logs/l.log\n\n[socket]\n\nname = ./socket\nbacklog = 100\n" > build/confix.txt
|
||||
$(BUILD_DIR)/server &
|
||||
bash scripts/test2.sh
|
||||
pkill -1 server
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -106,12 +106,12 @@ size_t taglia_log(taglia_t *taglia, char *buf) {
|
||||
|
||||
size_t n, m;
|
||||
pthread_mutex_lock(&taglia->m);
|
||||
if((n = fwrite(buff, sizeof(char), sizeof(buff), taglia->file)) < 0){
|
||||
if((n = fwrite(buff, sizeof(char), strnlen(buff, sizeof(buff)), taglia->file)) < 0){
|
||||
perror("ERROR: fwrite");
|
||||
goto _error_taglia_log_mutex;
|
||||
}
|
||||
|
||||
if((m = fwrite(buf, sizeof(char), strlen(buff)+1, taglia->file)) < 0){
|
||||
if((m = fwrite(buf, sizeof(char), strlen(buf)+1, taglia->file)) < 0){
|
||||
// strlen conta il numero di caratteri senza EOF quindi aggiungiamo 1
|
||||
perror("ERROR: fwrite");
|
||||
goto _error_taglia_log_mutex;
|
||||
|
||||
@ -830,6 +830,7 @@ void clearWaiting(waiting_t **waiting) {
|
||||
|
||||
while (curr) {
|
||||
next = curr->next;
|
||||
if(curr->file)
|
||||
free(curr->file);
|
||||
free(curr);
|
||||
curr = next;
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
ini_free(config); \
|
||||
return 1; \
|
||||
} \
|
||||
var = calloc(strlen(var)+1, sizeof(char)); \
|
||||
var = calloc(strlen(buff)+1, sizeof(char)); \
|
||||
strncpy(var, buff, strlen(buff)+1);
|
||||
|
||||
|
||||
|
||||
8
scripts/test1.sh
Normal file
8
scripts/test1.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
./client -t 200 -f mysock -w testFiles/1 -D Wdir -W testFiles/1/file1 -r testFiles/1/file1 -d Rdir -R n=3 -p
|
||||
|
||||
exit 0
|
||||
|
||||
./client -t 200 -f mysock -w test -D Wdir -W test/filepesante -r test/filepesante -d Rdir -R n=3 -l test/filepesante -u test/filepesante -c test/filepesante -p
|
||||
|
||||
exit 0
|
||||
10
scripts/test2.sh
Normal file
10
scripts/test2.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
./client -t 200 -f mysock -w testFiles/1 -D Wdir -W testFiles/1/file1 -r testFiles/1/file1 -d Rdir -R n=3 -l testFiles/1/file1 -u testFiles/1/file1 -c testFiles/1/file1 -p &
|
||||
./client -t 200 -f mysock -w testFiles/2 -D Wdir -W testFiles/2/file6 -r testFiles/2/file6 -d Rdir -R n=3 -l testFiles/2/file6 -u testFiles/2/file6 -c testFiles/2/file6 -p &
|
||||
./client -t 200 -f mysock -w testFiles/3 -D Wdir -W testFiles/3/file11 -r testFiles/3/file11 -d Rdir -R n=3 -l testFiles/3/file11 -u testFiles/3/file11 -c testFiles/3/file11 -p &
|
||||
./client -t 200 -f mysock -w testFiles/4 -D Wdir -W testFiles/3/file11 -r testFiles/3/file11 -d Rdir -R n=3 -l testFiles/3/file11 -u testFiles/3/file11 -c testFiles/3/file11 -p &
|
||||
./client -t 200 -f mysock -w testFiles/5 -D Wdir -W testFiles/3/file11 -r testFiles/3/file11 -d Rdir -R n=3 -l testFiles/3/file11 -u testFiles/3/file11 -c testFiles/3/file11 -p &
|
||||
wait
|
||||
|
||||
exit 0
|
||||
@ -174,7 +174,7 @@ int main(int argc, char *argv[]) {
|
||||
queueT *queue = createQueue(maxFiles, maxSize);
|
||||
|
||||
// creo la lista dei client in attesa a una lock
|
||||
waiting_t *waiting;
|
||||
waiting_t *waiting = NULL;
|
||||
|
||||
// creo la threadpool
|
||||
threadpool_t *pool = NULL;
|
||||
@ -186,7 +186,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// scrivo sul log
|
||||
n = snprintf(buf, sizeof(buf), "Creato threadpool di dimensione %d e lending size %d\n", threadsInPool, pendingSize);
|
||||
n = snprintf(buf, sizeof(buf), "Creato threadpool di dimensione %d e pending size %d\n", threadsInPool, pendingSize);
|
||||
if( n<0 ) {
|
||||
perror("snprintf");
|
||||
goto _cleanup;
|
||||
|
||||
1
testFiles/1/file1
Normal file
1
testFiles/1/file1
Normal file
@ -0,0 +1 @@
|
||||
a
|
||||
1
testFiles/1/file2
Normal file
1
testFiles/1/file2
Normal file
@ -0,0 +1 @@
|
||||
b
|
||||
1
testFiles/1/file3
Normal file
1
testFiles/1/file3
Normal file
@ -0,0 +1 @@
|
||||
c
|
||||
1
testFiles/1/file4
Normal file
1
testFiles/1/file4
Normal file
@ -0,0 +1 @@
|
||||
d
|
||||
1
testFiles/1/file5
Normal file
1
testFiles/1/file5
Normal file
@ -0,0 +1 @@
|
||||
e
|
||||
1
testFiles/2/file10
Normal file
1
testFiles/2/file10
Normal file
@ -0,0 +1 @@
|
||||
5
|
||||
1
testFiles/2/file6
Normal file
1
testFiles/2/file6
Normal file
@ -0,0 +1 @@
|
||||
1
|
||||
1
testFiles/2/file7
Normal file
1
testFiles/2/file7
Normal file
@ -0,0 +1 @@
|
||||
2
|
||||
1
testFiles/2/file8
Normal file
1
testFiles/2/file8
Normal file
@ -0,0 +1 @@
|
||||
3
|
||||
1
testFiles/2/file9
Normal file
1
testFiles/2/file9
Normal file
@ -0,0 +1 @@
|
||||
4
|
||||
1
testFiles/3/file11
Normal file
1
testFiles/3/file11
Normal file
@ -0,0 +1 @@
|
||||
!
|
||||
1
testFiles/3/file12
Normal file
1
testFiles/3/file12
Normal file
@ -0,0 +1 @@
|
||||
"
|
||||
1
testFiles/3/file13
Normal file
1
testFiles/3/file13
Normal file
@ -0,0 +1 @@
|
||||
$
|
||||
1
testFiles/3/file14
Normal file
1
testFiles/3/file14
Normal file
@ -0,0 +1 @@
|
||||
%
|
||||
1
testFiles/3/file15
Normal file
1
testFiles/3/file15
Normal file
@ -0,0 +1 @@
|
||||
&
|
||||
1
testFiles/4/file16
Normal file
1
testFiles/4/file16
Normal file
@ -0,0 +1 @@
|
||||
Progetto
|
||||
1
testFiles/4/file17
Normal file
1
testFiles/4/file17
Normal file
@ -0,0 +1 @@
|
||||
di
|
||||
1
testFiles/4/file18
Normal file
1
testFiles/4/file18
Normal file
@ -0,0 +1 @@
|
||||
Laboratorio
|
||||
1
testFiles/4/file19
Normal file
1
testFiles/4/file19
Normal file
@ -0,0 +1 @@
|
||||
di
|
||||
1
testFiles/4/file20
Normal file
1
testFiles/4/file20
Normal file
@ -0,0 +1 @@
|
||||
Sistemi
|
||||
1
testFiles/5/file21
Normal file
1
testFiles/5/file21
Normal file
@ -0,0 +1 @@
|
||||
Operativi
|
||||
1
testFiles/5/file22
Normal file
1
testFiles/5/file22
Normal file
@ -0,0 +1 @@
|
||||
Introduzione
|
||||
1
testFiles/5/file23
Normal file
1
testFiles/5/file23
Normal file
@ -0,0 +1 @@
|
||||
Lo
|
||||
1
testFiles/5/file24
Normal file
1
testFiles/5/file24
Normal file
@ -0,0 +1 @@
|
||||
studente
|
||||
1
testFiles/5/file25
Normal file
1
testFiles/5/file25
Normal file
@ -0,0 +1 @@
|
||||
deve
|
||||
1
testFiles/6/f1
Normal file
1
testFiles/6/f1
Normal file
File diff suppressed because one or more lines are too long
1
testFiles/6/f2
Normal file
1
testFiles/6/f2
Normal file
File diff suppressed because one or more lines are too long
1
testFiles/6/f3
Normal file
1
testFiles/6/f3
Normal file
File diff suppressed because one or more lines are too long
1
testFiles/6/f4
Normal file
1
testFiles/6/f4
Normal file
File diff suppressed because one or more lines are too long
1
testFiles/6/f5
Normal file
1
testFiles/6/f5
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user