diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-07-30 21:31:51 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-07-30 21:59:39 +0530 |
commit | 72cf8cfcc59f792ff48eb28c3f760678dc10090c (patch) | |
tree | 1aca1af04efe127296bbb5b134babb904a3dbf19 /tests/dag.c | |
parent | 1778164794b39d2613b02783bef9beee683de866 (diff) |
tests: init
Diffstat (limited to 'tests/dag.c')
-rw-r--r-- | tests/dag.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/dag.c b/tests/dag.c new file mode 100644 index 0000000..065536b --- /dev/null +++ b/tests/dag.c @@ -0,0 +1,80 @@ +#include <stdio.h> +#include <errno.h> +#include <string.h> + +#include "util.h" +#include "queue.h" +#include "evanix.h" +#include "solver_sjf.h" +#include "test.h" + +/* + * A C A C + * \ + + / = \ / + * B B B B + */ + +struct evanix_opts_t evanix_opts = { + .close_unused_fd = false, + .isflake = false, + .ispipelined = true, + .isdryrun = false, + .max_build = 0, + .system = NULL, + .solver_report = false, + .check_cache_status = false, + .solver = solver_sjf, + .break_evanix = false, +}; + +static void test_merge() +{ + FILE *stream; + struct job *job, *a, *b, *c; + struct queue_thread *qt; + int ret; + + stream = fopen("../tests/dag_merge.json", "r"); + test_assert(stream != NULL); + + ret = queue_thread_new(&qt, stream); + if (ret < 0) + goto out_free_stram; + + + /* A */ + ret = job_read(qt->stream, &job); + test_assert(ret == JOB_READ_SUCCESS); + ret = queue_htab_job_merge(&job, &qt->queue->htab); + test_assert(ret >= 0); + a = job; + + /* B */ + ret = job_read(qt->stream, &job); + test_assert(ret == JOB_READ_SUCCESS); + ret = queue_htab_job_merge(&job, &qt->queue->htab); + test_assert(ret >= 0); + b = job; + + /* C */ + ret = job_read(qt->stream, &job); + test_assert(ret == JOB_READ_SUCCESS); + ret = queue_htab_job_merge(&job, &qt->queue->htab); + test_assert(ret >= 0); + c = job; + + ret = job_read(qt->stream, &job); + test_assert(ret == JOB_READ_EOF); + + test_assert(a->deps[0] == b); + test_assert(a->deps[0] == c->deps[0]); + +out_free_stram: + fclose(stream); + queue_thread_free(qt); +} + +int main(void) +{ + test_run(test_merge); +} |