Add create_file_node
test; Ensure fifo is unique in create_fifo_node
test
This commit is contained in:
parent
d12eb47b25
commit
ad3d5dfddc
3 changed files with 33 additions and 0 deletions
|
@ -69,6 +69,7 @@ tests += create_dir_node
|
||||||
tests += create_symlink_node
|
tests += create_symlink_node
|
||||||
tests += create_fifo_node
|
tests += create_fifo_node
|
||||||
tests += create_dev_node
|
tests += create_dev_node
|
||||||
|
tests += create_file_node
|
||||||
|
|
||||||
total != echo $(tests) | wc -w | awk '{ print $$1 }'
|
total != echo $(tests) | wc -w | awk '{ print $$1 }'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "haggis.h"
|
#include "haggis.h"
|
||||||
|
@ -12,6 +13,7 @@ int main() {
|
||||||
|
|
||||||
map = haggis_linkmap_init();
|
map = haggis_linkmap_init();
|
||||||
assert(map != NULL);
|
assert(map != NULL);
|
||||||
|
unlink(path);
|
||||||
assert(mkfifo(path, 0644) == 0);
|
assert(mkfifo(path, 0644) == 0);
|
||||||
node = haggis_create_node(path, sha256, map);
|
node = haggis_create_node(path, sha256, map);
|
||||||
assert(node->filetype.tag == fifo);
|
assert(node->filetype.tag == fifo);
|
||||||
|
|
30
test/create_file_node.c
Normal file
30
test/create_file_node.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "haggis.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
haggis_linkmap *map;
|
||||||
|
haggis_node *node;
|
||||||
|
char *path = "create_dev_node.c";
|
||||||
|
uint8_t sum[] = {244, 223, 223, 246, 142, 83, 37, 211, 255, 37, 242,
|
||||||
|
205, 42, 85, 31, 70, 231, 76, 202, 195, 160, 254, 206,
|
||||||
|
31, 9, 11, 16, 182, 166, 176, 237, 131};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
map = haggis_linkmap_init();
|
||||||
|
assert(map != NULL);
|
||||||
|
node = haggis_create_node(path, sha256, map);
|
||||||
|
assert(node->filetype.tag == normal);
|
||||||
|
for (i = 0; i < 32; i++) {
|
||||||
|
assert(sum[i] == node->filetype.f_type.file.cksum.sum.sha256[i]);
|
||||||
|
}
|
||||||
|
assert(node->filetype.f_type.file.len.val == 526);
|
||||||
|
assert(memcmp(path, node->name.name, 17) == 0);
|
||||||
|
haggis_node_deinit(node);
|
||||||
|
haggis_linkmap_deinit(map);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue