DPLAN/Src/DATA/out_1.check 0000444 0001751 0000144 00000000071 11017227546 014573 0 ustar susanna users dplan: test1.dat: 01-08-2008 cinzia#Pagare rata macchina
DPLAN/Src/DATA/out_2.check 0000444 0001751 0000144 00000000047 11017227546 014577 0 ustar susanna users dplan: test1.dat: No events registered
DPLAN/Src/DATA/out_3.check 0000444 0001751 0000144 00000000170 11017244465 014574 0 ustar susanna users dplan: test1.dat: 04-06-2008 davide#Scrivere a Nadia
dplan: test1.dat: 04-06-2008 davide#Telefonare zia luigina (20:00)
DPLAN/Src/DATA/out_4.check 0000444 0001751 0000144 00000000261 11017244676 014602 0 ustar susanna users dplan: test1.dat: 01-06-2008 cinzia#Pagare rata macchina
dplan: test1.dat: 04-06-2008 davide#Scrivere a Nadia
dplan: test1.dat: 04-06-2008 davide#Telefonare zia luigina (20:00)
DPLAN/Src/DATA/out_5.check 0000444 0001751 0000144 00000000047 11017227546 014602 0 ustar susanna users dplan: test1.dat: No events registered
DPLAN/Src/DATA/out_6.check 0000444 0001751 0000144 00000000162 11017227546 014601 0 ustar susanna users dplan: test2.dat: 01-08-2008 cinzia#Pagare rata macchina
dplan: test2.dat: 19-08-2008 luigi#Appuntamento dentista
DPLAN/Src/DATA/out_a6.check 0000444 0001751 0000144 00000000046 11017231241 014726 0 ustar susanna users dplan: test2.dat: Agenda not existent
DPLAN/Src/DATA/out_a7.check 0000444 0001751 0000144 00000000426 11017243041 014732 0 ustar susanna users dplan: test1.dat: 02-12-2008 maria#Parrucchiere (ore 14:00)
dplan: test1.dat: 04-12-2008 fufi#miao miao miao
dplan: test1.dat: 11-12-2008 gigi#Veterinario
dplan: test1.dat: 12-12-2008 cinzia#Cena con Vito
dplan: test1.dat: 31-12-2008 luigi#ecco___ un po' di strani^%! caratteri
DPLAN/Src/DATA/out_b1.check 0000444 0001751 0000144 00000000030 11017235636 014727 0 ustar susanna users dplan: ciccio1: Created
DPLAN/Src/DATA/out_b2.check 0000444 0001751 0000144 00000000030 11017235636 014730 0 ustar susanna users dplan: ciccio2: Created
DPLAN/Src/DATA/out_b3.check 0000444 0001751 0000144 00000000030 11017235636 014731 0 ustar susanna users dplan: ciccio3: Created
DPLAN/Src/DATA/out_b4.check 0000444 0001751 0000144 00000000030 11017235636 014732 0 ustar susanna users dplan: ciccio4: Created
DPLAN/Src/DATA/out_b5.check 0000444 0001751 0000144 00000000030 11017235636 014733 0 ustar susanna users dplan: ciccio5: Created
DPLAN/Src/DATA/out_b6.check 0000444 0001751 0000144 00000000030 11017235636 014734 0 ustar susanna users dplan: ciccio6: Created
DPLAN/Src/DATA/out_b7.check 0000444 0001751 0000144 00000000030 11017235636 014735 0 ustar susanna users dplan: ciccio7: Created
DPLAN/Src/DATA/out_b8.check 0000444 0001751 0000144 00000000030 11017235636 014736 0 ustar susanna users dplan: ciccio8: Created
DPLAN/Src/DATA/out_b9.check 0000444 0001751 0000144 00000000030 11017235636 014737 0 ustar susanna users dplan: ciccio9: Created
DPLAN/Src/DATA/out_bf.check 0000444 0001751 0000144 00000000043 11017235636 015020 0 ustar susanna users dplan: ciccio: Agenda not existent
DPLAN/Src/DATA/test1.dat 0000444 0001751 0000144 00000001762 11017243532 014300 0 ustar susanna users 01-02-2008 davide#Bollo auto
11-05-2008 cinzia#Lezione di Piano (11:00)
01-06-2008 cinzia#Pagare rata macchina
04-06-2008 davide#Scrivere a Nadia
04-06-2008 davide#Telefonare zia luigina (20:00)
01-07-2008 cinzia#Pagare rata macchina
01-08-2008 cinzia#Pagare rata macchina
19-08-2008 luigi#Appuntamento dentista
01-09-2008 cinzia#Pagare rata macchina
01-01-2009 cinzia#Pagare ISI
DPLAN/Src/DATA/test2.dat 0000444 0001751 0000144 00000001762 11017005620 014273 0 ustar susanna users 01-02-2008 davide#Bollo auto
11-05-2008 cinzia#Lezione di Piano (11:00)
01-06-2008 cinzia#Pagare rata macchina
04-06-2008 davide#Telefonare zia luigina (20:00)
04-06-2008 davide#Scrivere a Nadia
01-07-2008 cinzia#Pagare rata macchina
01-08-2008 cinzia#Pagare rata macchina
19-08-2008 luigi#Appuntamento dentista
01-09-2008 cinzia#Pagare rata macchina
01-01-2009 cinzia#Pagare ISI
DPLAN/Src/lbase.h 0000600 0001751 0000144 00000004630 11017504533 013264 0 ustar susanna users /**
* \file
* \author lcs08
* \brief rappresentazione eventi
*
* Rappresentazione di un evento e funzioni base di conversione/manipolazione
*/
#ifndef __LBASE_H__
#define __LBASE_H__
/** Lunghezza di un record evento su file */
#define LRECORD 100
/** Lunghezza stringa data */
#define LDATA 10
/** Lunghezza stringa utente */
#define LUTENTE 8
/** Lunghezza stringa descrizione */
#define LDESCRIZIONE 80
/** Lunghezza nome agenda */
#define LAGENDA 20
/** Rappresentazione di un evento */
typedef struct {
/** data formato gg-mm-aaaa */
char data[LDATA + 1];
/** utente che ha registrato l'evento */
char utente[LUTENTE + 1];
/** descrizione evento */
char descrizione[LDESCRIZIONE + 1];
}
evento_t;
/** Trasforma un record di tipo evento su file
es: 01-02-2008 davide\#Bollo auto
in una struttura di tipo evento
\param r la stringa che rappresenta l'evento
\retval p (puntatore al nuovo evento) se la conversione e' andata a buon fine e non si sono verificati errori
\retval NULL se si e' verificato un errore (setta errno)
*/
evento_t* convertiRecord(char r[]);
/** Trasforma una struttura di tipo evento in una stringa r nel formato record tipo evento su file
es: 01-02-2008 davide\#Bollo auto
\param r la stringa da riempire (conterra' il record secondo il formato)
\param e la struttura evento da convertire
\retval 0 se tutto e' andato a buon fine
\retval -1 altrimenti
*/
int convertiEvento(evento_t* e,char r[]);
/**
Controlla se un'evento ha data corrispondente a quella contenuta in una stringa il formato della stringa puo' essere:
`gg-mm-aaaa' (es `12-12-1998') oppure
`**-mm-aaaa' (es `**-12-1998') nel secondo caso il matching e' positivo per tutti gli eventi del mese considerato
\param b la data da cercare in formato stringa
\param e l'evento da verificare
\retval 1 se c'e' un matching fra data ed evento
\retval 0 se NON c'e' un matching fra data ed evento
\retval -1 se si e' verificato un errore (es data mal formattata)
*/
int matchData(char b[],evento_t* e);
/**
Controlla se uno dei campi dell'evento contiene un pattern specificato
\param p il pattern da cercare (p==NULL da sempre match positivo)
\param e l'evento da verificare
\retval 1 se c'e' un matching fra pattern ed evento
\retval 0 se NON c'e' un matching
\retval -1 se si e' verificato un errore
*/
int matchPattern(char p[],evento_t* e);
#endif
DPLAN/Src/lcscom.h 0000644 0001751 0000144 00000007577 11017505003 013474 0 ustar susanna users /** \file
* \author lcs07 lcs08
* \brief libreria di comunicazione server client
*
* Libreria che definisce l'interfaccia di comunicazione fra client e server
* (canali di comunicazione realizzati con socket AF_UNIX)
*/
/* -= TIPI =- */
#ifndef _LCSCOM_H
#define _LCSCOM_H
/**
Messaggio
* La struttura \c message_t rappresenta un messaggio tra client e server
* - \c type rappresenta il tipo del messaggio
* - \c length rappresenta la lunghezza in byte del campo buffer
* - \c buffer e' il puntatore al messaggio
*
*
*/
typedef struct {
char type; /**< tipo del messaggio */
unsigned int length; /**< lunghezza in byte */
char* buffer; /**< buffer messaggio */
} message_t;
/** fine dello stream, connessione chiusa dal peer */
#define SEOF -2
/** tipo dei messaggi di errore */
#define MSG_ERROR 'E'
/** tipo dei messaggi di OK */
#define MSG_OK '0'
/** tipo dei messaggi di creazione agenda */
#define MSG_MKAGENDA 'C'
/** tipo dei messaggi di distruzione agenda */
#define MSG_RMAGENDA 'Q'
/** tipo dei messaggi di inserimento evento */
#define MSG_INSERT 'D'
/** tipo dei messaggi di rimozione pattern */
#define MSG_RMPATTERN 'R'
/** tipo dei messaggi di richiesta eventi per un certo mese */
#define MSG_EMESE 'M'
/** tipo dei messaggi di richiesta eventi per un certo giorno */
#define MSG_EGIORNO 'G'
/** Error Path Too Long (exceeding UNIX_PATH_MAX) */
#define SOCKNAMETOOLONG -11
/** nome del server socket AF_UNIX */
#define SKTNAME "dsock"
/** directory del server socket */
#define TMP "./tmp/"
/** tipo descrittore canale di ascolto (server) */
typedef int serverChannel_t;
/** tipo descrittore del canale di comunicazione (server e client) */
typedef int channel_t;
/* -= FUNZIONI =- */
/** Crea un channel di ascolto AF_UNIX
* \param path pathname del canale di ascolto da creare
* \return
* - s il descrittore del channel di ascolto (s>0)
* - -1 in casi di errore (sets errno)
* - SOCKNAMETOOLONG se il nome del socket eccede UNIX_PATH_MAX
*/
serverChannel_t createServerChannel(const char* path);
/** Distrugge un channel di ascolto
* \param s il channel di ascolto da distruggere
* \return
* - 0 se tutto ok,
* - -1 se errore (sets errno)
*/
int closeSocket(serverChannel_t s);
/** accetta una connessione da parte di un client
* \param s channel di ascolto su cui si vuole ricevere la connessione
* \return
* - c il descrittore del channel di trasmissione con il client
* - -1 in casi di errore (sets errno)
*/
channel_t acceptConnection(serverChannel_t s);
/** legge un messaggio dal channel di trasmissione
* \param sc channel di trasmissione
* \param msg struttura che conterra' il messagio letto
* (deve essere allocata all'esterno della funzione,
* tranne il campo buffer)
* \return
* - -1 se errore (errno settato),
* - SEOF se EOF sul socket
* - lung lunghezza del buffer letto, se OK
*/
int receiveMessage(channel_t sc, message_t *msg);
/** scrive un messaggio sul channel di trasmissione
* \param sc channel di trasmissione
* \param msg struttura che contiene il messaggio da scrivere
* \return
* - -1 se errore (sets errno)
* - n il numero di caratteri inviati (se OK)
*/
int sendMessage(channel_t sc, message_t *msg);
/** Chiude un socket
* \param sc il descrittore del channel da chiudere
* \return
* - 0 se tutto ok
* - -1 se errore (sets errno)
*/
int closeConnection(channel_t sc);
/** crea un channel di trasmissione verso il server
* \param path nome del server socket
* \return
* - c (c>0) il channel di trasmissione
* - -1 in casi di errore (sets errno)
* - SOCKNAMETOOLONG se il nome del socket eccede UNIX_PATH_MAX
*/
channel_t openConnection(const char* path);
#endif
DPLAN/Src/llist.h 0000600 0001751 0000144 00000004623 11017502565 013332 0 ustar susanna users /**
* \file
* \author lcs08
* \brief agenda come lista di eventi
*
* Rappresentazione di una agenda come lista concatenata di eventi e funzioni manipolazione lista
*/
#ifndef __LIST_H__
#define __LIST_H__
/** Nodo della lista che raccoglie gli eventi di una agenda */
typedef struct elem_t {
/** puntatore all'evento */
evento_t* ptev;
/** puntatore all'elemento successivo */
struct elem_t* next;
}
elem_t;
/**
Aggiunge un nuovo evento alla lista di eventi
\param agenda il puntatore al puntatore alla testa della lista
in cui inserire l'evento
\param ev puntatore all'evento da inserire
\retval 0 se l'inserzione e' andata a buon fine
\retval 1 altrimenti
*/
int add(elem_t** agenda, evento_t* ev);
/** Restituisce la lista degli eventi che contiene tutti gli eventi che hanno un match con una data
\param data la data di cui dobbiamo cercare il match (es 12-12-1997 oppure **-12-1997)
\param agenda l'agenda in cui cercare
\param trovati il puntatore al puntatore alla testa della lista risultato della ricerca
\retval n il numero di elementi contenuti nella lista risultato oppure
\retval -1 in caso di errore
*/
int cerca(char data[], elem_t* agenda, elem_t** trovati);
/** Rimuove dalla lista gli eventi che hanno un match con il pattern richiesto in uno qualsiasi dei campi
\param pattern il pattern da cercare
\param agenda l'agenda in cui cercare
\retval p il puntatore alla lista aggiornata
*/
elem_t* rimuovi(char pattern[], elem_t* agenda);
/**
* Legge il file ingresso e inserisce tutti i record in una lista concatenata
\param ingresso il file di ingresso
\param agenda il puntatore al puntatore alla testa della lista risultato del caricamento
\retval n il numero dei record letti ed inseriti nella lista se tutto e' andato a buon fine
\retval -1 altrimenti
*/
int loadAgenda(FILE* ingresso, elem_t** agenda);
/**
Scrive tutti i record della lista 'agenda' nel file 'uscita' secondo il formato predefinito
\param uscita il file su cui scrivere il contenuto della lista
\param agenda il puntatore alla testa della lista
\retval n il numero di voci registrate oppure
\retval -1 se si e' verificato un errore
*/
int storeAgenda(FILE* uscita, elem_t* agenda);
/**
dealloca tutta la memoria occupata dalla lista
\param lista puntatore al primo elemento della lista da deallocare
*/
void dealloca_lista(elem_t* lista);
#endif
DPLAN/Src/testparse 0000755 0001751 0000144 00000001502 11015523325 013766 0 ustar susanna users #!/bin/sh
if ./dplan -g gigi ; then
return 1
fi
if ./dplan -u gigi ; then
return 1
fi
if ./dplan agenda -d 15-10-2003 -u gigi ; then
exit 1
fi
if ./dplan agenda -d 10-2003 -u gigi#hhhhh ; then
exit 1
fi
if ./dplan agenda -d 10-10-2003 -u gigioooo0#hhhhh ; then
exit 1
fi
if ./dplan agenda -d 10-10-2003 -u gigiooooooooooooooooooooo#hhhhh ; then
exit 1
fi
if ./dplan agenda -d 10-10-2003 -u gigi#hhhhhkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk ; then
exit 1
fi
if ./dplan agenda -k; then
exit 1
fi
if ./dplan agenda -r; then
exit 1
fi
if ./dplan -m 12-09-2008 agenda; then
exit 1
fi
if ./dplan -c gigimmmmmmmmmmmmmmmmmmmmmmmmmm ; then
exit 1
fi
exit 0 DPLAN/Src/errparse.check 0000444 0001751 0000144 00000001313 11015534666 014660 0 ustar susanna users dplan: Formato scorretto del comando
dplan: Formato scorretto del comando
dplan: gigi: Formato evento non corretto (manca #)
dplan: 10-2003: Data non corretta
dplan: gigioooo0: Formato evento non corretto (Utente max 8 caratteri)
dplan: gigiooooooooooooooooooooo: Formato evento non corretto (Utente max 8 caratteri)
dplan: gigi#hhhhhkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk: Formato evento non corretto (Descrizione max 80 caratteri)
dplan: -k: Opzione errata
dplan: -r: Opzione errata
dplan: 12-09-2008 Data non corretta
dplan: gigimmmmmmmmmmmmmmmmmmmmmmmmmm: Agenda max 20 caratteri
DPLAN/Src/testfunz 0000755 0001751 0000144 00000001621 11017032153 013634 0 ustar susanna users #!/bin/sh
#test creazione
./dplan -c ciccio
./dplan -c ciccio
./dplan -q ciccio
./dplan -q test1.dat
#test lettura eventi giornalieri e mensili
./dplan test1.dat -g 01-08-2008
./dplan test1.dat -g 02-08-2008
./dplan test1.dat -g 04-06-2008
./dplan test1.dat -m 06-2008
./dplan test1.dat -m 11-2008
#test rimozione pattern / distruzioni / creazioni
./dplan test1.dat -r maria
./dplan test1.dat -r luigi
./dplan priscilla -r luigi
./dplan test1.dat -r cinzia
./dplan test1.dat -r da
./dplan test1.dat -q
./dplan test1.dat -c
# test inserzioni e rimozioni
./dplan test1.dat -d 12-12-2008 -u gigi#Veterinario
./dplan test1.dat -d 02-12-2008 -u "maria#Parrucchiere (ore 14:00)"
./dplan test1.dat -d 12-12-2008 -u "cinzia#Cena con Vito"
./dplan test1.dat -d 31-12-2008 -u "luigi#ecco___ un po' di strani^%$@! caratteri"
./dplan test1.dat -d 04-12-2008 -u "fufi#miao miao miao"
./dplan test1.dat -m 12-2008
exit 0
DPLAN/Src/outfunz.check 0000444 0001751 0000144 00000002233 11017243542 014541 0 ustar susanna users dplan: ciccio: Created
dplan: ciccio: Cannot create, agenda already present
dplan: ciccio: Removed
dplan: test1.dat: Agenda not empty, cannot remove
dplan: test1.dat: 01-08-2008 cinzia#Pagare rata macchina
dplan: test1.dat: No events registered
dplan: test1.dat: 04-06-2008 davide#Scrivere a Nadia
dplan: test1.dat: 04-06-2008 davide#Telefonare zia luigina (20:00)
dplan: test1.dat: 01-06-2008 cinzia#Pagare rata macchina
dplan: test1.dat: 04-06-2008 davide#Scrivere a Nadia
dplan: test1.dat: 04-06-2008 davide#Telefonare zia luigina (20:00)
dplan: test1.dat: No events registered
dplan: maria: Success
dplan: luigi: Success
dplan: priscilla: Agenda not existent
dplan: cinzia: Success
dplan: da: Success
dplan: test1.dat: Removed
dplan: test1.dat: Created
dplan: 12-12-2008: Success
dplan: 02-12-2008: Success
dplan: 12-12-2008: Success
dplan: 31-12-2008: Success
dplan: 04-12-2008: Success
dplan: test1.dat: 02-12-2008 maria#Parrucchiere (ore 14:00)
dplan: test1.dat: 04-12-2008 fufi#miao miao miao
dplan: test1.dat: 12-12-2008 gigi#Veterinario
dplan: test1.dat: 12-12-2008 cinzia#Cena con Vito
dplan: test1.dat: 31-12-2008 luigi#ecco___ un po' di strani^%! caratteri
DPLAN/Src/testpar 0000755 0001751 0000144 00000006164 11066460177 013462 0 ustar susanna users #!/bin/sh
echo "Inizio test parallelo"
SOCK=./tmp/dsock
OUT=./OUT
echo "Test lettura eventi giornalieri e mensili (-g -m)"
#test lettura eventi giornalieri e mensili
./dplan test1.dat -g 01-08-2008 >${OUT}/out_1 &
./dplan test1.dat -g 02-08-2008 >${OUT}/out_2 &
./dplan test1.dat -g 04-06-2008 >${OUT}/out_3 &
./dplan test1.dat -m 06-2008 >${OUT}/out_4 &
./dplan test1.dat -m 11-2008 >${OUT}/out_5 &
./dplan test2.dat -m 08-2008 >${OUT}/out_6 &
wait
#controlliamo le risposte
for ((i=1;i<=6;i++)); do
if ! diff ${OUT}/out_$i ${OUT}/out_$i.check; then
echo Test failed: diff ${OUT}/out_$i ${OUT}/out_$i.check
exit 1
fi
done
echo "Test rimozioni (-r)"
#test rimozione pattern
./dplan test2.dat -r maria &
./dplan test2.dat -r luigi &
./dplan priscilla -r luigi &
./dplan test2.dat -r cinzia &
./dplan test2.dat -r da &
wait
if ! ./dplan test2.dat -q ; then
echo Pippo
fi
wait
echo "Test inserzioni (-d -u)"
# test inserzioni
./dplan test1.dat -d 11-12-2008 -u gigi#Veterinario &
./dplan test1.dat -d 02-12-2008 -u "maria#Parrucchiere (ore 14:00)" &
./dplan test1.dat -d 12-12-2008 -u "cinzia#Cena con Vito" &
./dplan test1.dat -d 31-12-2008 -u "luigi#ecco___ un po' di strani^%$@! caratteri" &
./dplan test1.dat -d 04-12-2008 -u "fufi#miao miao miao" &
wait
#test lettura eventi giornalieri e mensili
./dplan test1.dat -g 01-08-2008 >${OUT}/out_a1 &
./dplan test1.dat -g 02-08-2008 >${OUT}/out_a2 &
./dplan test1.dat -g 04-06-2008 >${OUT}/out_a3 &
./dplan test1.dat -m 06-2008 >${OUT}/out_a4 &
./dplan test1.dat -m 11-2008 >${OUT}/out_a5 &
./dplan test2.dat -m 08-2008 >${OUT}/out_a6 &
./dplan test1.dat -m 12-2008 >${OUT}/out_a7 &
wait
#controlliamo le risposte
for ((i=1;i<=5;i++)); do
if ! diff ${OUT}/out_a$i ${OUT}/out_$i.check; then
echo Test failed: diff ${OUT}/out_a$i ${OUT}/out_$i.check
exit 1
fi
done
for ((i=6;i<=7;i++)); do
if ! diff ${OUT}/out_a$i ${OUT}/out_a$i.check; then
echo Test failed: diff ${OUT}/out_a$i ${OUT}/out_a$i.check
exit 1
fi
done
echo "Test creazioni (-c)"
#test creazione
for ((i=1;i<=9;i++)); do
./dplan -c ciccio$i >${OUT}/out_b$i &
done
./dplan -q ciccio >${OUT}/out_bf &
wait
if ! killall -PIPE dserver; then
echo Errore: SIGPIPE non gestito
exit 1
fi
wait
for ((i=1;i<=9;i++)); do
if ! diff ${OUT}/out_b$i ${OUT}/out_b$i.check; then
echo Test failed: diff ${OUT}/out_b$i ${OUT}/out_b$i.check
exit 1
fi
done
if ! diff ${OUT}/out_bf ${OUT}/out_bf.check; then
echo Test failed: diff ${OUT}/out_bf ${OUT}/out_bf.check
exit 1
fi
echo "Test gestione segnali e cleanup"
if ! killall -w -TERM dserver; then
echo Errore: SIGTERM non gestito
exit 1
fi
# controllo rimozione socket
if [ -f $SOCK ] ; then
echo Errore: $SOCK non rimosso
exit 1
fi
# controllo directory
if rmdir tmp2; then
echo Errore: tmp2 vuota
exit 1
fi
if ! [ -f ./tmp2/test1.dat ] ; then
echo Errore: tmp2/test1.dat non presente
exit 1
fi
if [ -f ./tmp2/test2.dat ] ; then
echo Errore: tmp2/test2.dat era stata rimossa
exit 1
fi
for ((i=1;i<=9;i++)); do
if ! [ -f ./tmp2/ciccio$i ] ; then
echo Errore: tmp2/ciccio$i non presente
exit 1
fi
done
exit 0
DPLAN/Src/Makefile 0000600 0001751 0000144 00000005310 11066460474 013472 0 ustar susanna users ###############################################################
###############################################################
## Makefile progetto finale lcs08
##
###############################################################
###############################################################
#File(s) *.c *.h README relazione etc (da consegnare)
FILE_DA_CONSEGNARE=
# Compiler flags
CFLAGS = -Wall -pedantic -g
# Compiler
CC = gcc
#directory librerie
LIBDIR = ../lib
# nome libreria
LIBNAME = libdplan.a
.PHONY: all clean lib test1 test2 test3 testfinale consegna docu testiniziale
all: dserver dplan
@echo -e 'MAKE ALL completato\a'
clean:
-rm -fr *.o *~
# Lista degli object file da inserire nella libreria libdplan.a (***DA COMPLETARE***)
OBJS = lbase.o llist.o\
# Target per la creazione della libreria
lib: $(OBJS)
ar -r $(LIBNAME) $(OBJS)
cp $(LIBNAME) $(LIBDIR)
# Target per la creazione degli eseguibili "dserver" e "dplan"
# (***DA COMPLETARE/MODIFICARE***)
dserver: dserver.o lcscom.o check.o
$(CC) $(CFLAGS) -L$(LIBDIR) $^ -o dserver -lpthread -ldplan
dplan: dplan.o lcscom.o check.o
$(CC) $(CFLAGS) -L$(LIBDIR) $^ -o dplan -ldplan
lcscom.o: lcscom.c lcscom.h
$(CC) $(CFLAGS) $(INC) -c $<
# NON MODIFICARE
# crea la documentazione html
docu:
make -C ../Doc
# invoca i test cunit
testiniziale:
make lib
make -C ../Test/Test1 test
make -C ../Test/Test2 test
# test parsing
test1: dplan
./testparse 1> errparse 2> .test.err
diff errparse errparse.check
@echo -e "\a\n\t\t *** Test parsing superato! ***\n"
# test funzionale
test2: dserver dplan
-killall dserver
-rm -fr tmp/
-mkdir tmp
-rm -fr tmp2/
-mkdir tmp2
cp DATA/test* tmp2/
chmod 644 tmp2/*
./dserver tmp2 1> .server.out 2> .server.err &
./testfunz 1> outfunz 2> .test.err
diff outfunz outfunz.check
@echo -e "\a\n\t\t *** Test funzionale superato! ***\n"
# test parallelo
test3: dserver dplan
-killall -w dserver
-rm -fr tmp/
mkdir tmp
-rm -fr OUT/
mkdir OUT
-rm -fr tmp2/
mkdir tmp2
cp DATA/test* tmp2/
cp DATA/*.check OUT/
chmod 644 tmp2/*
./dserver tmp2 1> .server.out 2> .server.err &
./testpar 2> .test.err
@echo -e "\a\n\t\t *** Test parallelo superato! ***\n"
testfinale:
make clean
make lib
make all
make -C ../Test/Test1 test
make -C ../Test/Test2 test
make test1
make test2
make test3
@echo -e "\a\n\t\t *** Test finale superato! ***\n"
######################################
SUBJECT="lcs08: consegna progetto finale DPLAN"
FILENAME=$(USER)-f3dplan.tar
consegna :
make testfinale
./gruppo-check.pl < ./gruppo.txt
tar -cvf $(FILENAME) gruppo.txt $(FILE_DA_CONSEGNARE)
mpack -s $(SUBJECT) $(FILENAME) susanna@di.unipi.it
@echo -e "\a\n\t\t*** Progetto Finale CONSEGNATO! ***\n"
DPLAN/Test/Test1/Makefile 0000644 0001751 0000144 00000001657 11013063070 014663 0 ustar susanna users ############################################
############################################
## This Makefile is in charge of building ##
## the test for the format utility. ##
############################################
############################################
#
# Header file for cunit
INC = -I /usr/include/CUnit/ -I ../../Src
# Compiler flags
CFLAGS = -Wall -pedantic -g
# Compiler
CC = gcc
# libreria da testare
LIB_PATH = -L ../../lib/
.PHONY : test clean
format_test: format_test.o format_suite.o
$(CC) $(LIB_PATH) -o format_test $^ -lcunit -ldplan
format_test.o: format_test.c format.h
$(CC) $(CFLAGS) $(INC) -c $<
format_suite.o: format_suite.c format.h
$(CC) $(CFLAGS) $(INC) -c $<
# Target di testing
test: format_test
-rm test1.dat
-rm test2.dat
cp Dati/test1.dat .
chmod 644 test1.dat
./format_test
@echo -e "\n\n\a *** Test format superato! ***\n"
clean:
rm -f *.o
rm -f format_test
rm -f *~ DPLAN/Test/Test1/format.h 0000644 0001751 0000144 00000000164 11013060176 014660 0 ustar susanna users /** Lunghezza dei record su file */
#define LMAX 100
/** Numero massimo dei record di test */
#define MAXNTEST 100
DPLAN/Test/Test1/format_suite.c 0000644 0001751 0000144 00000007225 11017505325 016075 0 ustar susanna users /**
* \file
*
* \brief Test suite per le funzioni di conversione/matching eventi
*/
#include
#include
#include
#include
#include
#include
#include "CUnit.h"
#include "TestDB.h"
#include "Basic.h"
#include "format.h"
#include "lbase.h"
/** Primo file di test*/
#define FILE_TEST1 "./test1.dat"
/** Secondo file di test */
#define FILE_TEST2 "./test2.dat"
/** date per la prova di matchData */
char* date[] = {
"12-10-2010",
"01-02-2008",
"01-08-2008",
"19-08-2008",
"11-05-2008",
"04-06-2008",
"**-02-2008",
"**-06-2008",
"01-*-2008",
NULL
};
/** pattern per la prova di matchPattern */
char* pattern[] = {
"macchina",
"dentista",
"Pagare",
"gatto",
"luigi",
"8-",
NULL
};
/** numero di matching attesi per la prova di matchPattern */
int npatternmatch[] = {
4,
1,
5,
0,
2,
2,
};
/** numero di matching attesi per la prova di matchData */
int nmatch[] = {
0,
1,
1,
1,
1,
2,
1,
3,
-10,
};
/** Funzione di inizializzazione della suite */
int success_init(void) { return 0; }
/** Funzione di clean up della suite */
int success_clean(void) { return 0; }
/**
* Questa funzione legge e scrive un'agenda effettuando controlli
* necessari a verificare che il file sia stato formattato correttamente
* e che la conversione sia corretta
*
* \param fagenda nome del file agenda
* \param ftest nome del file in cui verranno scritte le voci covertite
*/
void run_testagenda (char *fagenda, char* ftest) {
char record[LRECORD+2], pbu[MAXNTEST][LRECORD+1], pb[LRECORD+1];
evento_t* ev[MAXNTEST];
FILE *fsa;
/* prossima posizione libera nell'array di eventi */
int i=0;
int l,k;
/*
* Apertura del file agenda
*/
fsa = fopen(fagenda, "r");
CU_ASSERT_PTR_NOT_NULL_FATAL(fsa);
/*
* Lettura e caricamento eventi nell'array
*/
while(fgets(record,LRECORD + 2,fsa) != NULL) {
CU_ASSERT_EQUAL_FATAL(record[LRECORD], '\n');
record[LRECORD]='\0';
strncpy(pbu[i],record,LRECORD+1);
CU_TEST_FATAL(i < MAXNTEST);
ev[i]=convertiRecord(record);
CU_ASSERT_NOT_EQUAL_FATAL(ev[i],NULL);
i++;
}
fclose(fsa);
printf("lette %d voci\n",i);
/*
* Trasformazione voci nel formato stringa
*/
for ( l=0; l