9 static Tube
*default_tube
;
16 TUBE_ASSIGN(default_tube
, make_tube("default"));
17 j
= make_job(1, 0, 1, 0, default_tube
);
18 assertf(j
->r
.pri
== 1, "priority should match");
26 TUBE_ASSIGN(default_tube
, make_tube("default"));
27 a
= make_job(1, 0, 1, 0, default_tube
);
28 b
= make_job(1 << 27, 0, 1, 0, default_tube
);
30 assertf(job_pri_less(a
, b
), "should be less");
38 TUBE_ASSIGN(default_tube
, make_tube("default"));
39 a
= make_job(1, 0, 1, 0, default_tube
);
40 b
= make_job(1, 0, 1, 0, default_tube
);
43 assertf(job_pri_less(a
, b
), "should be less");
47 cttest_job_large_pris()
51 TUBE_ASSIGN(default_tube
, make_tube("default"));
52 a
= make_job(1, 0, 1, 0, default_tube
);
53 b
= make_job(-5, 0, 1, 0, default_tube
);
55 assertf(job_pri_less(a
, b
), "should be less");
57 a
= make_job(-5, 0, 1, 0, default_tube
);
58 b
= make_job(1, 0, 1, 0, default_tube
);
60 assertf(!job_pri_less(a
, b
), "should not be less");
64 cttest_job_hash_free()
69 TUBE_ASSIGN(default_tube
, make_tube("default"));
70 j
= make_job_with_id(0, 0, 1, 0, default_tube
, jid
);
73 assertf(!job_find(jid
), "job should be missing");
77 cttest_job_hash_free_next()
80 uint64 aid
= 97, bid
= 12386;
82 TUBE_ASSIGN(default_tube
, make_tube("default"));
83 b
= make_job_with_id(0, 0, 1, 0, default_tube
, bid
);
84 a
= make_job_with_id(0, 0, 1, 0, default_tube
, aid
);
86 assertf(a
->ht_next
== b
, "b should be chained to a");
90 assertf(a
->ht_next
== NULL
, "job should be missing");
94 cttest_job_all_jobs_used()
98 TUBE_ASSIGN(default_tube
, make_tube("default"));
99 j
= make_job(0, 0, 1, 0, default_tube
);
100 assertf(get_all_jobs_used() == 1, "should match");
102 x
= allocate_job(10);
103 assertf(get_all_jobs_used() == 1, "should match");
106 assertf(get_all_jobs_used() == 1, "should match");
109 assertf(get_all_jobs_used() == 0, "should match");
113 cttest_job_100_000_jobs()
117 TUBE_ASSIGN(default_tube
, make_tube("default"));
118 for (i
= 0; i
< 100000; i
++) {
119 make_job(0, 0, 1, 0, default_tube
);
121 assertf(get_all_jobs_used() == 100000, "should match");
123 for (i
= 1; i
<= 100000; i
++) {
124 job_free(job_find(i
));
126 fprintf(stderr
, "get_all_jobs_used() => %zu\n", get_all_jobs_used());
127 assertf(get_all_jobs_used() == 0, "should match");
131 ctbench_job_make(int n
)
134 Job
**j
= calloc(n
, sizeof *j
);
135 TUBE_ASSIGN(default_tube
, make_tube("default"));
138 for (i
= 0; i
< n
; i
++) {
139 j
[i
] = make_job(0, 0, 1, 0, default_tube
);
143 for (i
= 0; i
< n
; i
++) {
150 ctbench_job_free(int n
)
153 Job
**j
= calloc(n
, sizeof *j
);
154 TUBE_ASSIGN(default_tube
, make_tube("default"));
155 for (i
= 0; i
< n
; i
++) {
156 j
[i
] = make_job(0, 0, 1, 0, default_tube
);
160 for (i
= 0; i
< n
; i
++) {