aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format1
-rw-r--r--flake.lock6
-rw-r--r--flake.nix6
-rw-r--r--include/test.h26
-rw-r--r--src/jobs.c9
-rw-r--r--src/meson.build13
-rw-r--r--src/solver_sjf.c2
-rw-r--r--src/util.c2
-rw-r--r--tests/dag.c16
-rw-r--r--tests/meson.build5
10 files changed, 52 insertions, 34 deletions
diff --git a/.clang-format b/.clang-format
index 8424e95..acc151f 100644
--- a/.clang-format
+++ b/.clang-format
@@ -15,3 +15,4 @@ ForEachMacros:
- 'LIST_FOREACH'
- 'CIRCLEQ_FOREACH'
- 'cJSON_ArrayForEach'
+ - 'HASH_ITER'
diff --git a/flake.lock b/flake.lock
index 65ae907..81623d6 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1719075281,
- "narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=",
+ "lastModified": 1722421184,
+ "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=",
"owner": "NixOs",
"repo": "nixpkgs",
- "rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af",
+ "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index 5014f4d..b87e287 100644
--- a/flake.nix
+++ b/flake.nix
@@ -33,6 +33,7 @@
valgrind
clang-tools # clang-format
flamegraph
+ nix-eval-jobs
linuxKernel.packages.linux_6_6.perf
hyperfine
nix-eval-jobs
@@ -50,6 +51,11 @@
{
default = self.packages.${system}.evanix;
evanix = pkgs.callPackage ./package.nix { };
+ evanix-asan = self.packages.${system}.evanix.overrideAttrs (
+ _: previousAttrs: {
+ mesonFlags = previousAttrs.mesonFlags ++ [ (lib.mesonOption "b_sanitize" "address") ];
+ }
+ );
evanix-py = pkgs.python3Packages.callPackage ./python-package.nix { };
pythonWithEvanix =
diff --git a/include/test.h b/include/test.h
index 64716cc..45b786c 100644
--- a/include/test.h
+++ b/include/test.h
@@ -3,21 +3,21 @@
char *__curtestname = "<none>";
-#define test_run(func) \
- do { \
- char *orig = __curtestname; \
- __curtestname = #func; \
- func(); \
- __curtestname = orig; \
+#define test_run(func) \
+ do { \
+ char *orig = __curtestname; \
+ __curtestname = #func; \
+ func(); \
+ __curtestname = orig; \
} while (0)
-#define test_assert(cond) \
- do { \
- if (!(cond)) { \
- fprintf(stderr, "%s:%d: %s: test_assert failed: %s\n", __FILE__, __LINE__, \
- __curtestname, #cond); \
- abort(); \
- } \
+#define test_assert(cond) \
+ do { \
+ if (!(cond)) { \
+ fprintf(stderr, "%s:%d: %s: test_assert failed: %s\n", \
+ __FILE__, __LINE__, __curtestname, #cond); \
+ abort(); \
+ } \
} while (0)
#endif
diff --git a/src/jobs.c b/src/jobs.c
index cb5fe3b..043dac0 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -302,6 +302,8 @@ static int job_read_cache(struct job *job)
i++;
}
+ ret = 0;
+
out_free_line:
free(line);
fclose(nix_build_stream);
@@ -395,6 +397,8 @@ int job_read(FILE *stream, struct job **job)
goto out_free;
}
+ ret = JOB_READ_SUCCESS;
+
out_free:
cJSON_Delete(root);
if (ret != JOB_READ_SUCCESS)
@@ -522,7 +526,6 @@ int jobs_init(FILE **stream, char *expr)
{
size_t argindex;
char *args[4];
- int ret;
argindex = 0;
args[argindex++] = XSTR(NIX_EVAL_JOBS_PATH);
@@ -532,9 +535,7 @@ int jobs_init(FILE **stream, char *expr)
args[argindex++] = NULL;
/* the package is wrapProgram-ed with nix-eval-jobs */
- ret = vpopen(stream, XSTR(NIX_EVAL_JOBS_PATH), args, VPOPEN_STDOUT);
-
- return ret;
+ return vpopen(stream, XSTR(NIX_EVAL_JOBS_PATH), args, VPOPEN_STDOUT);
}
void job_stale_set(struct job *job)
diff --git a/src/meson.build b/src/meson.build
index b88a0da..4217858 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -19,4 +19,15 @@ e = executable(
c_args: [f'-DNIX_EVAL_JOBS_PATH=@NIX_EVAL_JOBS_PATH@'],
)
-test('evanix', e, args: '--help')
+
+foreach solver : ['sjf', 'highs', 'conformity']
+ test(f'evanix-@solver@', e, args: [
+ '--dry-run',
+ '--close-unused-fd=false',
+ '--max-build=3',
+ '--solver-report',
+ f'--solver=@solver@',
+ '--flake',
+ '../#packages.x86_64-linux'
+ ])
+endforeach
diff --git a/src/solver_sjf.c b/src/solver_sjf.c
index 34d85ec..c81f718 100644
--- a/src/solver_sjf.c
+++ b/src/solver_sjf.c
@@ -1,5 +1,5 @@
-#include <queue.h>
#include <errno.h>
+#include <queue.h>
#include "evanix.h"
#include "jobs.h"
diff --git a/src/util.c b/src/util.c
index 2a81670..8ffbb71 100644
--- a/src/util.c
+++ b/src/util.c
@@ -69,7 +69,7 @@ int vpopen(FILE **stream, const char *file, char *const argv[], vpopen_t type)
return -errno;
}
- return 0;
+ return ret;
}
close(fd[0]);
diff --git a/tests/dag.c b/tests/dag.c
index 806aa75..c49bf34 100644
--- a/tests/dag.c
+++ b/tests/dag.c
@@ -1,12 +1,12 @@
-#include <stdio.h>
#include <errno.h>
+#include <stdio.h>
#include <string.h>
-#include "util.h"
-#include "queue.h"
#include "evanix.h"
-#include "solver_sjf.h"
+#include "jobs.h"
+#include "queue.h"
#include "test.h"
+#include "util.h"
/*
* A C A C
@@ -23,13 +23,13 @@ struct evanix_opts_t evanix_opts = {
.system = NULL,
.solver_report = false,
.check_cache_status = false,
- .solver = solver_sjf,
+ .solver = NULL,
.break_evanix = false,
};
static void test_merge()
{
- struct job *job, *a, *b, *c;
+ struct job *job, *a, *b, *c, *tmp;
FILE *stream;
int ret;
struct job *htab = NULL;
@@ -65,6 +65,10 @@ static void test_merge()
test_assert(a->deps[0] == c->deps[0]);
fclose(stream);
+ HASH_ITER (hh, htab, job, tmp)
+ HASH_DEL(htab, job);
+ job_free(a);
+ job_free(c);
}
int main(void)
diff --git a/tests/meson.build b/tests/meson.build
index 22ce6b8..d8f1ef6 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -5,11 +5,6 @@ dag_test = executable(
'../src/jobs.c',
'../src/util.c',
'../src/queue.c',
- '../src/build.c',
- '../src/jobid.c',
- '../src/solver_conformity.c',
- '../src/solver_highs.c',
- '../src/solver_sjf.c',
],
include_directories: evanix_inc,