piler/unit_tests/common.c
Janos SUTO 4a5e57816c Refactored unit tests
Signed-off-by: Janos SUTO <sj@acts.hu>
2018-11-03 15:48:37 +01:00

37 lines
850 B
C

/*
* common.c
*/
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <locale.h>
#include <stdbool.h>
#include <assert.h>
#include "../src/piler.h"
int setup_and_parse_message(struct session_data *sdata, struct parser_state *state, struct data *data, char *filename, struct config *cfg){
struct stat st;
if(stat(filename, &st) != 0){
fprintf(stderr, "%s is not found, skipping\n", filename);
return 1;
}
init_session_data(sdata, cfg);
sdata->delivered = 0;
sdata->tot_len = st.st_size;
snprintf(sdata->ttmpfile, SMALLBUFSIZE-1, "%s", filename);
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename);
snprintf(sdata->tmpframe, SMALLBUFSIZE-1, "%s.m", filename);
*state = parse_message(sdata, 1, data, cfg);
post_parse(sdata, state, cfg);
return 0;
}