-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
153 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef _TEST_H | ||
#define _TEST_H | ||
|
||
char *__curtestname = "<none>"; | ||
|
||
#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(); \ | ||
} \ | ||
} while (0) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"name":"a","attr":"a","drvPath":"/nox/store/a.drv","inputDrvs":{"/nox/store/b.drv":["out"]},"outputs":{"out":"/nox/store/a"}} | ||
{"attr":"b","name":"b","drvPath":"/nox/store/b.drv","inputDrvs":{},"outputs":{"out":"/nox/store/b"}} | ||
{"name":"c","attr":"c","drvPath":"/nox/store/c.drv","inputDrvs":{"/nox/store/b.drv":["out"]},"outputs":{"out":"/nox/store/b"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dag_test = executable( | ||
'dag_test', | ||
[ | ||
'dag.c', | ||
'../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, | ||
dependencies: [ cjson_dep, highs_dep ], | ||
) | ||
|
||
test('dag', dag_test) |