Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1/* -*- C -*-
2 * Serene programming language
3 * Copyright (C) 2019-2026 Sameer Rahmani <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19// Uncomment only if you want to run a debugger on the tests binary
20#define TEST_NO_FORK
21
22#if !defined(_WIN32)
23# ifndef _POSIX_C_SOURCE
24# define _POSIX_C_SOURCE 200809L
25# endif
26#endif
27
28#include "base.h"
29#include "fiber_tests.h"
30#include "hashmap_tests.h"
31#include "mm_tests.h"
32#include "pqmh_tests.h"
33#include "reactor_io_tests.h"
34#include "reactor_tests.h"
35#include "seq_tests.h"
36#include "spsc_ring_tests.h"
37
38// The value model and its dependents are only built with the Serene layer, so
39// their tests are too.
40#ifdef SRN_WITH_SERENE
41# include "context_tests.h"
42# include "ns_tests.h"
43# include "symbol_tests.h"
44# include "value_tests.h"
45#endif
46
47#if defined(SERENE_TESTS)
48hmap_hash_t hmap_hash(const srn_context_t *ctx, const void *k, size_t len) {
49 (void)ctx;
50 if (k == nullptr || len == 0) {
51 return 1;
52 }
53
54 const uint8_t *p = (const uint8_t *)k;
55 // Very high collision rate. Only 256 possible hashes
56 return (uint32_t)p[0];
57}
58#endif
59
68#ifdef __linux__
69 REACTOR_IO_TESTS(ENTRY),
70#endif
71
72#ifdef SRN_WITH_SERENE
77#endif
78 {NULL, NULL},
79};
#define TEST_LIST
Definition acutest.h:73
#define ENTRY(name, test)
Definition base.h:28
#define CTX_TESTS(X)
#define FIBER_TESTS(X)
Definition fiber_tests.h:29
hmap_hash_t hmap_hash(const srn_context_t *ctx, const void *data, size_t len)
This is a simple hack to mock the hash function during tests to force a high collision hashing functi...
Definition hashmap.c:77
HMAP_HASH_TYPE hmap_hash_t
Definition hashmap.h:61
#define HMAP_TESTS(X)
#define MM_TESTS(X)
Definition mm_tests.h:25
#define NS_TESTS(X)
Definition ns_tests.h:30
#define PQMH_TESTS(X)
Definition pqmh_tests.h:27
#define REACTOR_TESTS(X)
#define SEQ_TESTS(X)
Definition seq_tests.h:28
#define SPSC_RING_TESTS(X)
#define SYMBOL_TESTS(X)
#define VALUE_TESTS(X)
Definition value_tests.h:29