seahag/test/create_file_node.c

34 lines
1,015 B
C
Raw Normal View History

#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include "haggis.h"
#include "mq.h"
int main() {
haggis_linkmap *map;
haggis_node *node;
haggis_mq mq;
char *path = "create_dev_node.c";
2023-10-17 20:58:48 -04:00
uint8_t sum[] = {169, 53, 195, 76, 81, 143, 0, 198, 121, 240,
35, 26, 176, 103, 200, 73, 229, 249, 238, 164,
54, 32, 101, 168, 23, 58, 200, 254, 228, 193,
215, 6};
int i;
map = haggis_linkmap_init();
assert(map != NULL);
assert(haggis_mq_init(&mq) == 0);
node = haggis_create_node(path, sha256, map, &mq);
assert(node->filetype.tag == normal);
for (i = 0; i < 32; i++) {
assert(sum[i] == node->filetype.f_type.file.cksum.sum.sha256[i]);
}
2023-10-17 20:58:48 -04:00
assert(node->filetype.f_type.file.len.val == 746);
assert(memcmp(path, node->name.name, 17) == 0);
haggis_node_deinit(node);
haggis_linkmap_deinit(map);
return 0;
}