|
@@ -11,32 +11,20 @@
|
|
#include "../cryptothread.h"
|
|
#include "../cryptothread.h"
|
|
#include "../packet.h"
|
|
#include "../packet.h"
|
|
#include "../util.h"
|
|
#include "../util.h"
|
|
|
|
+#include "test_util.h"
|
|
|
|
|
|
START_TEST(test_recognize_notag){
|
|
START_TEST(test_recognize_notag){
|
|
struct packet_info *info;
|
|
struct packet_info *info;
|
|
- uint8_t *data;
|
|
+ uint8_t *packet;
|
|
- FILE *fp;
|
|
|
|
- uint64_t fsize;
|
|
|
|
|
|
|
|
|
|
|
|
- fp = fopen("data/packet_untagged.dat", "rb");
|
|
+ if(!read_file("data/packet_untagged.dat", &packet)){
|
|
- if (fp == NULL) {
|
|
|
|
- perror("fopen");
|
|
|
|
ck_abort();
|
|
ck_abort();
|
|
}
|
|
}
|
|
|
|
|
|
- fseek(fp, 0, SEEK_END);
|
|
|
|
- fsize = ftell(fp);
|
|
|
|
- fseek(fp, 0, SEEK_SET);
|
|
|
|
- data = smalloc(fsize);
|
|
|
|
-
|
|
|
|
- int32_t result = fread(data, fsize, 1, fp);
|
|
|
|
-
|
|
|
|
- fclose(fp);
|
|
|
|
-
|
|
|
|
info = smalloc(sizeof(struct packet_info));
|
|
info = smalloc(sizeof(struct packet_info));
|
|
|
|
|
|
- extract_packet_headers(data, info);
|
|
+ extract_packet_headers(packet, info);
|
|
|
|
|
|
ck_assert_int_eq(check_handshake(info), 0);
|
|
ck_assert_int_eq(check_handshake(info), 0);
|
|
}
|
|
}
|
|
@@ -49,21 +37,10 @@ START_TEST(test_recognize_tag){
|
|
uint64_t fsize;
|
|
uint64_t fsize;
|
|
|
|
|
|
|
|
|
|
- fp = fopen("data/packet_tagged.dat", "rb");
|
|
+ if(!read_file("data/packet_tagged.dat", &data)){
|
|
- if (fp == NULL) {
|
|
|
|
- perror("fopen");
|
|
|
|
ck_abort();
|
|
ck_abort();
|
|
}
|
|
}
|
|
|
|
|
|
- fseek(fp, 0, SEEK_END);
|
|
|
|
- fsize = ftell(fp);
|
|
|
|
- fseek(fp, 0, SEEK_SET);
|
|
|
|
- data = smalloc(fsize);
|
|
|
|
-
|
|
|
|
- int32_t result = fread(data, fsize, 1, fp);
|
|
|
|
-
|
|
|
|
- fclose(fp);
|
|
|
|
-
|
|
|
|
info = smalloc(sizeof(struct packet_info));
|
|
info = smalloc(sizeof(struct packet_info));
|
|
|
|
|
|
extract_packet_headers(data, info);
|
|
extract_packet_headers(data, info);
|