summaryrefslogtreecommitdiff
path: root/libcr/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libcr/tests')
-rw-r--r--libcr/tests/test_matrix.c24
-rw-r--r--libcr/tests/test_matrix/config.h14
2 files changed, 38 insertions, 0 deletions
diff --git a/libcr/tests/test_matrix.c b/libcr/tests/test_matrix.c
new file mode 100644
index 0000000..eaa4bdc
--- /dev/null
+++ b/libcr/tests/test_matrix.c
@@ -0,0 +1,24 @@
+/* libcr/tests/test_matrix.c - Tests for libcr
+ *
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <libcr/coroutine.h>
+
+int a = 1;
+
+COROUTINE init_cr(void *) {
+ cr_begin();
+ a = 2;
+ cr_end();
+}
+
+int main() {
+ coroutine_add("init", init_cr, NULL);
+ coroutine_main();
+ if (a != 2)
+ return 1;
+ coroutine_main();
+ return 0;
+}
diff --git a/libcr/tests/test_matrix/config.h b/libcr/tests/test_matrix/config.h
new file mode 100644
index 0000000..978b9ac
--- /dev/null
+++ b/libcr/tests/test_matrix/config.h
@@ -0,0 +1,14 @@
+/* config.h - Compile-time configuration for libcr test_matrix
+ *
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+#define CONFIG_COROUTINE_STACK_SIZE_DEFAULT (4*1024)
+#define CONFIG_COROUTINE_NAME_LEN 16
+#define CONFIG_COROUTINE_NUM 2
+
+#endif /* _CONFIG_H_ */