Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retool tests #88

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

C4M_DEV_CFG="--buildtype=debug -Duse_memcheck=on -Ddev_mode=true"
C4M_RELEASE_CFG="--buildtype=release"
C4M_DEBUG_EXTRA="-Duse_ubsan=enabled -Duse_asan=enabled -Dshow_preprocessor_config=enabled"
C4M_DEBUG_EXTRA="-Duse_ubsan=enabled -Duse_asan=enabled -Dshow_preprocessor_config=enabled -Dforkless_tests=enabled"
C4M_TEST_CFG=${C4M_DEV_CFG}


Expand Down
3 changes: 3 additions & 0 deletions include/adts/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "con4m.h"

typedef int (*c4m_sort_fn)(const void *, const void *);

extern void *c4m_list_get(c4m_list_t *, int64_t, bool *);
extern void c4m_list_append(c4m_list_t *list, void *item);
extern void c4m_list_add_if_unique(c4m_list_t *list,
Expand All @@ -21,3 +23,4 @@ extern void c4m_list_set_slice(c4m_list_t *,
extern bool c4m_list_contains(c4m_list_t *, c4m_obj_t);
extern c4m_list_t *c4m_list_copy(c4m_list_t *);
extern c4m_list_t *c4m_list_shallow_copy(c4m_list_t *);
extern void c4m_list_sort(c4m_list_t *, c4m_sort_fn);
2 changes: 2 additions & 0 deletions include/con4m/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <sys/random.h>
#include <threads.h>
#include <endian.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif

#if defined(__MACH__)
Expand Down
11 changes: 7 additions & 4 deletions include/con4m/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@
#define C4M_GC_DEFAULT_OFF 0
#endif

#if defined(C4M_DEBUG) && !defined(C4M_BACKTRACE_SUPPORTED)
#warning "Cannot add debug stack traces to exceptions: libbacktrace not supported"
#endif

#ifndef C4M_GCT_INIT
#define C4M_GCT_INIT C4M_GC_DEFAULT_ON
#endif
Expand Down Expand Up @@ -218,3 +214,10 @@
#ifndef C4M_MAX_GC_ROOTS
#define C4M_MAX_GC_ROOTS (1 << 15)
#endif

#ifndef C4M_TEST_SUITE_TIMEOUT_SEC
#define C4M_TEST_SUITE_TIMEOUT_SEC 1
#endif
#ifndef C4M_TEST_SUITE_TIMEOUT_USEC
#define C4M_TEST_SUITE_TIMEOUT_USEC 0
#endif
2 changes: 2 additions & 0 deletions include/util/cbacktrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ extern void c4m_print_c_backtrace();

extern c4m_grid_t *c4m_get_c_backtrace();
extern void c4m_static_c_backtrace();
extern void c4m_set_crash_callback(void (*)());
extern void c4m_set_show_trace_on_crash(bool);
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ else
endif
endif

if get_option('forkless_tests').enabled()
c_args = c_args + ['-DC4M_TEST_WITHOUT_FORK']
endif

backtrace = cc.find_library('backtrace', required: false)

if backtrace.found()
Expand Down
7 changes: 7 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ option(
value: 'auto',
description: 'Use undefined behavior sanitizer',
)

option(
'forkless_tests',
type: 'feature',
value: 'auto',
description: 'Run test suite without forking',
)
10 changes: 10 additions & 0 deletions src/adts/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ c4m_list_set(c4m_list_t *list, int64_t ix, void *item)
void
c4m_list_append(c4m_list_t *list, void *item)
{
// Warning; this being in place and taking a user callback is a
// recipe for danger on the lock.
lock_list(list);
if (list->append_ix >= list->length) {
list_auto_resize(list);
Expand All @@ -100,6 +102,14 @@ c4m_list_append(c4m_list_t *list, void *item)
return;
}

void
c4m_list_sort(c4m_list_t *list, c4m_sort_fn f)
{
lock_list(list);
qsort(list->data, list->append_ix, sizeof(int64_t *), f);
unlock_list(list);
}

static inline void *
c4m_list_get_base(c4m_list_t *list, int64_t ix, bool *err)
{
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,8 @@ c4m_format_tokens(c4m_file_compile_ctx *ctx)
c4m_ka(5),
"header_rows",
c4m_ka(1),
"container_tag",
c4m_ka("table2"),
"stripe",
c4m_ka(true)));

Expand Down
8 changes: 5 additions & 3 deletions src/compiler/scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ c4m_symbol_lookup(c4m_scope_t *local_scope,
c4m_grid_t *
c4m_format_scope(c4m_scope_t *scope)
{
uint64_t len;
uint64_t len = 0;
hatrack_dict_value_t *values;
c4m_grid_t *grid = c4m_new(c4m_type_grid(),
c4m_kw("start_cols",
Expand All @@ -397,8 +397,10 @@ c4m_format_scope(c4m_scope_t *scope)
c4m_type_utf8());
int64_t nexttid = 0;

values = hatrack_dict_values_sort(scope->symbols,
&len);
if (scope != NULL) {
values = hatrack_dict_values_sort(scope->symbols,
&len);
}

if (len == 0) {
grid = c4m_new(c4m_type_grid(), c4m_kw("start_cols", c4m_ka(1)));
Expand Down
Loading