mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-24 10:33:22 +03:00
cleans up tests from previous commit, backporting to 32-bit
This commit is contained in:
parent
b9d893fc80
commit
6cb7a1a97a
@ -15,9 +15,9 @@ worker_objs = $(shell echo $(worker) | sed 's/\.c/.o/g')
|
||||
|
||||
all_objs = $(common_objs) $(daemon_objs) $(worker_objs)
|
||||
all_srcs = $(common) $(daemon) $(worker)
|
||||
all_exes = ./build/mug_tests ./build/jam_tests ./build/hashtable_tests \
|
||||
./build/urbit ./build/urbit-worker
|
||||
|
||||
all_exes = ./build/mug_tests ./build/jam_tests \
|
||||
./build/noun_tests ./build/hashtable_tests \
|
||||
./build/urbit ./build/urbit-worker
|
||||
|
||||
# -Werror promotes all warnings that are enabled into errors (this is on)
|
||||
# -Wall issues all types of errors. This is off (for now)
|
||||
@ -31,10 +31,11 @@ CFLAGS := $(CFLAGS)
|
||||
|
||||
all: $(all_exes)
|
||||
|
||||
test: build/hashtable_tests build/jam_tests build/mug_tests
|
||||
test: build/hashtable_tests build/jam_tests build/mug_tests build/noun_tests
|
||||
./build/hashtable_tests
|
||||
./build/jam_tests
|
||||
./build/mug_tests
|
||||
./build/noun_tests
|
||||
|
||||
clean:
|
||||
rm -f ./tags $(all_objs) $(all_exes)
|
||||
@ -59,6 +60,11 @@ build/mug_tests: $(common_objs) tests/mug_tests.o
|
||||
@mkdir -p ./build
|
||||
@$(CC) $^ $(LDFLAGS) -o $@
|
||||
|
||||
build/noun_tests: $(common_objs) tests/noun_tests.o
|
||||
@echo CC -o $@
|
||||
@mkdir -p ./build
|
||||
@$(CC) $^ $(LDFLAGS) -o $@
|
||||
|
||||
build/urbit: $(common_objs) $(daemon_objs)
|
||||
@echo CC -o $@
|
||||
@mkdir -p ./build
|
||||
|
@ -1,69 +1,45 @@
|
||||
#include "all.h"
|
||||
|
||||
static void _setup(void);
|
||||
static void _test_bit_manipulation();
|
||||
static void _test_cache_replace_value(void);
|
||||
static void _test_cache_trimming(void);
|
||||
static void _test_no_cache(void);
|
||||
static void _test_skip_slot(void);
|
||||
|
||||
// defined in noun/hashtable.c
|
||||
c3_w _ch_skip_slot(c3_w mug_w, c3_w lef_w);
|
||||
|
||||
|
||||
/* main(): run all test cases.
|
||||
*/
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
_setup();
|
||||
|
||||
_test_bit_manipulation();
|
||||
_test_no_cache();
|
||||
_test_skip_slot();
|
||||
_test_cache_trimming();
|
||||
_test_cache_replace_value();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* _setup(): prepare for tests.
|
||||
*/
|
||||
static void
|
||||
_setup(void)
|
||||
{
|
||||
u3m_init();
|
||||
u3m_pave(c3y, c3n);
|
||||
u3m_pave(c3y, c3n);
|
||||
}
|
||||
|
||||
/* _test_bit_manipulation():
|
||||
*/
|
||||
static void
|
||||
_test_bit_manipulation()
|
||||
_test_bit_manipulation()
|
||||
{
|
||||
if (8 != sizeof(u3h_slot)){
|
||||
printf("wrong size\n");
|
||||
if ( sizeof(u3_noun) != sizeof(u3h_slot) ){
|
||||
c3_assert(!"wrong size\n");
|
||||
}
|
||||
|
||||
u3h_slot a = 0;
|
||||
|
||||
if (u3h_slot_is_null(a) != c3y){
|
||||
printf("nullity\n");
|
||||
c3_assert(!"nullity\n");
|
||||
}
|
||||
|
||||
|
||||
a = u3h_noun_be_warm(a);
|
||||
if (u3h_slot_is_warm(a) != c3y){
|
||||
printf("warmth\n");
|
||||
c3_assert(!"warmth\n");
|
||||
}
|
||||
|
||||
if (u3h_slot_is_null(a) != c3n){
|
||||
printf("nullity 2\n");
|
||||
}
|
||||
|
||||
a = u3h_noun_be_cold(a);
|
||||
if (u3h_slot_is_warm(a) != c3n){
|
||||
printf("coldness\n");
|
||||
c3_assert(!"nullity 2\n");
|
||||
}
|
||||
|
||||
|
||||
a = u3h_noun_be_cold(a);
|
||||
if (u3h_slot_is_warm(a) != c3n){
|
||||
c3_assert(!"coldness\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* _test_no_cache(): test a hashtable without caching.
|
||||
@ -72,12 +48,12 @@ static void
|
||||
_test_no_cache(void)
|
||||
{
|
||||
c3_w i_w;
|
||||
c3_w max_w = 3; // NOTFORCHECKIN
|
||||
c3_w max_w = 1000;
|
||||
|
||||
u3p(u3h_root) har_p = u3h_new();
|
||||
|
||||
for ( i_w = 0; i_w < max_w; i_w++ ) {
|
||||
u3h_put(har_p, i_w, i_w + max_w);
|
||||
u3h_put(har_p, i_w, i_w + max_w);
|
||||
}
|
||||
|
||||
for ( i_w = 0; i_w < max_w; i_w++ ) {
|
||||
@ -147,6 +123,8 @@ _test_cache_trimming(void)
|
||||
fprintf(stderr, "test_cache_trimming: ok\n");
|
||||
}
|
||||
|
||||
/* _test_cache_replace_value():
|
||||
*/
|
||||
static void
|
||||
_test_cache_replace_value(void)
|
||||
{
|
||||
@ -174,3 +152,21 @@ _test_cache_replace_value(void)
|
||||
}
|
||||
fprintf(stderr, "test_cache_replace_value: ok\r\n");
|
||||
}
|
||||
|
||||
/* main(): run all test cases.
|
||||
*/
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
_setup();
|
||||
|
||||
_test_bit_manipulation();
|
||||
_test_no_cache();
|
||||
_test_skip_slot();
|
||||
_test_cache_trimming();
|
||||
_test_cache_replace_value();
|
||||
|
||||
fprintf(stderr, "test_hashtable: ok\r\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,8 +96,181 @@ _test_jam(void)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "test_jam: ok\n");
|
||||
/* _test_cue_jam(): more jam/cue spot-checking, ported from the 64-bit effort
|
||||
*/
|
||||
static void
|
||||
_test_cue_jam()
|
||||
{
|
||||
// the boot msg from the worker
|
||||
{
|
||||
u3_noun dat = u3_nul;
|
||||
u3_noun in_1 = u3nc(c3__play, dat);
|
||||
u3_atom jam_1 = u3ke_jam(in_1);
|
||||
|
||||
u3_noun out_1 = u3ke_cue(jam_1);
|
||||
u3_noun head_out = u3h(out_1);
|
||||
u3_noun tail_out = u3t(out_1);
|
||||
|
||||
if (c3__play != head_out){
|
||||
printf("*** cue_jam 0 out head \n");
|
||||
}
|
||||
|
||||
if (u3_nul != tail_out){
|
||||
printf("*** cue_jam 0 out tail \n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// the boot msg from the worker, again,
|
||||
// but this time torn apart into bytes and rebuilt
|
||||
{
|
||||
u3_noun dat = u3_nul;
|
||||
u3_noun in_1 = u3nc(c3__play, dat);
|
||||
u3_atom jam_1 = u3ke_jam(in_1);
|
||||
|
||||
c3_y buf_y[1024];
|
||||
memset(buf_y, 0, 1024);
|
||||
c3_w len_w = u3r_met(3, jam_1);
|
||||
|
||||
u3r_bytes(0, // start byte
|
||||
len_w, // len
|
||||
buf_y, // buffer
|
||||
jam_1 ); // input noun
|
||||
|
||||
/// zip ....zap ... communicate between serf and king
|
||||
|
||||
u3_noun jam_2 = u3i_bytes(len_w, buf_y);
|
||||
|
||||
if ( c3n == u3r_sing(jam_1, jam_2) ) {
|
||||
printf("*** error in 6 byte message\n");
|
||||
}
|
||||
|
||||
u3_noun out_1 = u3ke_cue(jam_2);
|
||||
|
||||
u3_noun head_out = u3h(out_1);
|
||||
u3_noun tail_out = u3t(out_1);
|
||||
|
||||
if (c3__play != head_out){
|
||||
printf("*** cue_jam 0 out head \n");
|
||||
}
|
||||
|
||||
if (u3_nul != tail_out){
|
||||
printf("*** cue_jam 0 out tail \n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 1
|
||||
{
|
||||
|
||||
u3_atom in_1 = 1;
|
||||
u3_atom jam_1 = u3ke_jam(in_1);
|
||||
|
||||
if (12 != jam_1){
|
||||
printf("*** cue_jam 1a \n");
|
||||
}
|
||||
|
||||
u3_noun out_1 = u3ke_cue(jam_1);
|
||||
|
||||
if (1 != out_1){
|
||||
printf("*** cue_jam 1b \n");
|
||||
}
|
||||
}
|
||||
|
||||
// [ 1 1 ]
|
||||
{
|
||||
|
||||
u3_noun in_1 = u3i_cell(1, 1);
|
||||
u3_atom jam_1 = u3ke_jam(in_1);
|
||||
|
||||
if (817 != jam_1){
|
||||
printf("*** cue_jam 2 in \n");
|
||||
}
|
||||
|
||||
u3_noun out_1 = u3ke_cue(jam_1);
|
||||
|
||||
|
||||
u3_noun head_out = u3h(out_1);
|
||||
u3_noun tail_out = u3t(out_1);
|
||||
|
||||
if (1 != head_out){
|
||||
printf("*** cue_jam 2 out head \n");
|
||||
}
|
||||
|
||||
if (1 != tail_out){
|
||||
printf("*** cue_jam 2 out tail \n");
|
||||
}
|
||||
}
|
||||
|
||||
// [ 1 2 ]
|
||||
{
|
||||
|
||||
u3_noun in_1 = u3i_cell(1, 2);
|
||||
u3_atom jam_1 = u3ke_jam(in_1);
|
||||
|
||||
if (4657 != jam_1){
|
||||
printf("*** cue_jam 2 in \n");
|
||||
}
|
||||
|
||||
u3_noun out_1 = u3ke_cue(jam_1);
|
||||
|
||||
u3_noun head_out = u3h(out_1);
|
||||
u3_noun tail_out = u3t(out_1);
|
||||
|
||||
if (1 != head_out){
|
||||
printf("*** cue_jam 2 out head \n");
|
||||
}
|
||||
|
||||
if (2 != tail_out){
|
||||
printf("*** cue_jam 2 out tail \n");
|
||||
}
|
||||
}
|
||||
|
||||
// medium complicated cell
|
||||
// q
|
||||
// / \
|
||||
// a1 r
|
||||
// / \
|
||||
// b2 s
|
||||
// / \
|
||||
// c3 d4
|
||||
{
|
||||
u3_noun a = (u3_noun) 0x1;
|
||||
u3_noun b = (u3_noun) 0x2;
|
||||
u3_noun c = (u3_noun) 0x3;
|
||||
u3_noun d = (u3_noun) 0x4;
|
||||
|
||||
u3_noun s = u3i_cell(c, d);
|
||||
u3_noun r = u3i_cell(b, s);
|
||||
u3_noun q = u3i_cell(a, r);
|
||||
|
||||
u3_atom jam_1 = u3ke_jam(q);
|
||||
u3_noun out_1 = u3ke_cue(jam_1);
|
||||
|
||||
u3_noun a2 = u3h(out_1);
|
||||
u3_noun r2 = u3t(out_1);
|
||||
if (a2 != a){
|
||||
printf("*** _cue_jam: complicated a\n");
|
||||
}
|
||||
|
||||
u3_noun b2 = u3h(r2);
|
||||
u3_noun s2 = u3t(r2);
|
||||
if (b2 != b){
|
||||
printf("*** _cue_jam: complicated b\n");
|
||||
}
|
||||
|
||||
u3_noun c2 = u3h(s2);
|
||||
u3_noun d2 = u3t(s2);
|
||||
if (c2 != c){
|
||||
printf("*** _cue_jam: complicated c\n");
|
||||
}
|
||||
|
||||
if (d2 != d){
|
||||
printf("*** _cue_jam: complicated d\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* main(): run all test cases.
|
||||
@ -108,6 +281,9 @@ main(int argc, char* argv[])
|
||||
_setup();
|
||||
|
||||
_test_jam();
|
||||
_test_cue_jam();
|
||||
|
||||
fprintf(stderr, "test_jam: ok\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user