Skip to content

Commit

Permalink
move tests to /tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidson-Souza committed Sep 4, 2024
1 parent 0a4046d commit 578e107
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 12 deletions.
10 changes: 6 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ SUBDIRS = include
#libutreexo_cpp_la_SOURCES = include/cpp/utreexo.cpp
#libutreexo_cpp_la_LDFLAGS = -version-info 0:1:0

check_PROGRAMS = test_flat_file test_forest test_leaf_map
check_PROGRAMS = test_flat_file test_forest test_leaf_map test_utils

test_flat_file_SOURCES = src/test_flat_file.c
test_flat_file_SOURCES = tests/test_flat_file.c

test_leaf_map_SOURCES = src/test_leaf_map.c
test_leaf_map_SOURCES = tests/test_leaf_map.c

test_forest_SOURCES = src/forest_test.c
test_forest_SOURCES = tests/test_forest.c
test_forest_LDADD = libutreexo.la -lcrypto

test_utils_SOURCES = src/util.h tests/test_util_methods.c

lib_LTLIBRARIES = libutreexo.la
libutreexo_la_SOURCES = src/mmap_forest.c
2 changes: 1 addition & 1 deletion contrib/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

for file in $(find src/ include/ -name *.[h,c])
for file in $(find src/ include/ tests/ -name *.[h,c])
do
clang-format -i $file
done
6 changes: 3 additions & 3 deletions src/leaf_map_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ static inline void utreexo_leaf_map_set(utreexo_leaf_map *map,
do {
position = utreexo_leaf_map_get_pos(hash);
++hash;

pread(map->fd, &pnode, sizeof(utreexo_forest_node **), position);

if (pnode == NULL)
break;
} while (1);
Expand All @@ -121,7 +121,7 @@ static inline void utreexo_leaf_map_delete(utreexo_leaf_map *map,
++hash;

pread(map->fd, &pnode, sizeof(utreexo_forest_node *), position);

if (pnode == utreexo_thumbstone)
continue;

Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ static inline node_offset detect_offset(uint64_t pos, uint64_t num_leaves) {
tr -= 1;
}
return (node_offset){
.bits = pos,
.tree = (uint8_t)bigger_trees,
.depth = (uint8_t)(tr - nr),
.bits = !pos,
};
}

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/forest_test.c → tests/test_forest.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
static inline struct utreexo_forest get_test_forest(const char *filename) {
void *heap = NULL;
struct utreexo_forest_file *file = NULL;

char forest_name[100];
sprintf(forest_name, "forest_%s", filename);
utreexo_forest_file_init(&file, &heap, forest_name);
Expand Down Expand Up @@ -164,7 +164,8 @@ void test_add_single() {
utreexo_forest_file_init(&file, &heap, "forest_add_single.bin");

utreexo_leaf_map leaf_map;
utreexo_leaf_map_new(&leaf_map, "forest_leaves_single.bin", O_CREAT | O_RDWR, NULL);
utreexo_leaf_map_new(&leaf_map, "forest_leaves_single.bin", O_CREAT | O_RDWR,
NULL);

struct utreexo_forest p = {
.data = file,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/test_util_methods.c → tests/test_util_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdlib.h>

#include "test_utils.h"
#include "util.h"
#include <util.h>

void test_tree_rows() {
ASSERT_EQ(tree_rows(8), 3);
Expand Down
File renamed without changes.

0 comments on commit 578e107

Please sign in to comment.