tests: Added test filter
authorLukas Krickl <lukas@krickl.dev>
Mon, 2 Mar 2026 14:48:36 +0000 (15:48 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 2 Mar 2026 14:48:36 +0000 (15:48 +0100)
src/p_pc/u_string.c
src/t_command.h
src/test.c
src/tests/t_defs.h
src/u_string.h

index 7d1fd187eba9feed0a59466b5fa8399e93ade0da..8219e26a6ee5d1a7eb464a396398b2522593f34d 100644 (file)
@@ -16,3 +16,7 @@ int u_sprintf(char *buffer, const char *fmt, ...) {
 
                return res;
 }
+
+int u_strncmp(const char *s1, const char *s2, u32 n) {
+       return strncmp(s1, s2, n);
+}
index ad35c194cc7157d858ee37dff2e97aa6d6626d5d..0e92bf435f84e6cc3f085ba5c2e1ee72b4a4b50c 100644 (file)
@@ -47,7 +47,6 @@ struct t_command_queue {
        struct t_command buffer[T_COMMANDS_MAX];
 };
 
-extern struct t_command_queue t_command_queue;
 
 /* runs the command queue
  * returns number of commands run
index 3c84b30e59c78cfe98e62a490c6cc8aa6f0fe4db..3e11b59c2f63e4d9b1a3d2b8e13c021e49326782 100644 (file)
 #endif
 
 
+/**
+ * To only run specific test-cases
+ * run with test names as cli argumentst
+ * e.g. ./test arena 
+ * will only run arena test
+ */
 int main(int argc, char **argv) {
        p_io_init();
 
@@ -29,7 +35,7 @@ int main(int argc, char **argv) {
        T_TESTCASE("fixed-point-macro", t_test_fp_macros);
        T_TESTCASE("fixed-point-sqrt", t_test_fp_sqrt);
 
-       T_TESTCASE("command push", test_t_command_push);
+       T_TESTCASE("command-push", test_t_command_push);
 
   T_TESTEND("lrts test");
 
index efd7bf1ad9739b98890702b255e04a337acfd12a..9a210d124c99fcb0309845f5f89af361a65dde95 100644 (file)
  * Test functions should return 0 when they succeed otherwise 1
  */
 #define T_TESTCASE(name, fn) { \
-       T_TESTBEGIN(name); \
-       if (fn() == 0) {\
-               u_fprintf(u_stderr, "%s OK\n", name); \
-       } else {\
-               u_fprintf(u_stderr, "%s FAIL\n", name); \
-       }\
-       T_TESTEND(name); \
+       i32 i; \
+       struct lrts_config *c = lrts_cfg(); \
+       lrts_bool skip = c->argc != 0; \
+       for (i = 0; i < c->argc; i++) { \
+               if (u_strncmp(name, c->argv[i], strlen(name)) == 0) { \
+                       skip = LRTS_FALSE; \
+                       break; \
+               } \
+       } \
+       if (!skip) { \
+               T_TESTBEGIN(name); \
+               if (fn() == 0) {\
+                       u_fprintf(u_stderr, "%s OK\n", name); \
+               } else {\
+                       u_fprintf(u_stderr, "%s FAIL\n", name); \
+               }\
+               T_TESTEND(name); \
+       } \
 }
 
 #endif
index 3b191b7ff570bb9477c34bda27822eb71ac63ea7..8431cd05eda1cc5e78995cc949f3e2bda3ff422c 100644 (file)
@@ -6,4 +6,6 @@
 int u_vsprintf(char *buffer, const char *fmt, va_list args);
 int u_sprintf(char *buffer, const char *fmt, ...);
 
+int u_strncmp(const char *s1, const char *s2, u32 n);
+
 #endif