Skip to content

Commit

Permalink
ci: Update test-git-branch for new status format
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Feb 17, 2024
1 parent b1e0291 commit da2e4b7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
7 changes: 6 additions & 1 deletion ci-web/src/bin/get-test-job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ fn lockfile_exists(rc: &Ktestrc, commit: &str, test_name: &str, create: bool) ->
}
}

r.is_ok()
if let Ok(mut r) = r {
let _ = r.write_all(b"{ \"status\": \"in progress\" }");
true
} else {
false
}
}
}

Expand Down
10 changes: 2 additions & 8 deletions ci-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl TestStatus {
pub struct TestResultJson {
pub status: String,
pub msg: Option<String>,
pub duration: u64,
pub duration: Option<u64>,
}

#[derive(Clone, Debug)]
Expand All @@ -124,18 +124,13 @@ fn commitdir_get_results_fs(commit_dir: &Path) -> TestResultsMap {
f.read_to_string(&mut status_str).ok()?;

let status_str = status_str.trim();

println!("status_str: {:?}", status_str);

let status_json: TestResultJson = serde_json::from_str(&status_str).ok()?;

println!("status_json: {:?}", status_json);

Some(TestResult {
status: TestStatus::from_str(&status_json.status),
msg: status_json.msg,
starttime: f.metadata().ok()?.modified().ok()?.into(),
duration: status_json.duration,
duration: status_json.duration.unwrap_or(0),
})
}

Expand All @@ -146,7 +141,6 @@ fn commitdir_get_results_fs(commit_dir: &Path) -> TestResultsMap {
if let Ok(results_dir) = results_dir {
for d in results_dir.filter_map(|i| i.ok()) {
let r = read_test_result(&d);
println!("{:?}", r);
if let Some(r) = r {
results.insert(d.file_name().into_string().unwrap(), r);
}
Expand Down
8 changes: 4 additions & 4 deletions ci/test-git-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ run_test_job() {
t=$(echo "$t"|tr / .)

mkdir ktest-out/out/$TEST_NAME.$t
echo "IN PROGRESS" > ktest-out/out/$TEST_NAME.$t/status
echo '{ "status": "in progress" }' > ktest-out/out/$TEST_NAME.$t/status
done

make -C "$KTEST_DIR/lib" supervisor
Expand Down Expand Up @@ -159,14 +159,14 @@ run_test_job() {
t=${SUBTESTS[0]}
FNAME=$(echo "$t"|tr / .)

if grep -q "IN PROGRESS" ktest-out/out/$TEST_NAME.$FNAME/status; then
echo "NOT STARTED" > ktest-out/out/$TEST_NAME.$FNAME/status
if grep -q "in progress" ktest-out/out/$TEST_NAME.$FNAME/status; then
echo '{ "status": "not started" }' > ktest-out/out/$TEST_NAME.$FNAME/status
fi

for t in ${SUBTESTS[@]:1}; do
FNAME=$(echo "$t"|tr / .)

if grep -q "IN PROGRESS" ktest-out/out/$TEST_NAME.$FNAME/status; then
if grep -q "in progress" ktest-out/out/$TEST_NAME.$FNAME/status; then
SUBTESTS_REMAINING+=($t)
fi
done
Expand Down
1 change: 0 additions & 1 deletion lib/parse-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ parse_test_deps()

if [[ -z $ktest_tests ]]; then
echo "No tests found"
echo "TEST FAILED"
exit 1
fi

Expand Down
11 changes: 4 additions & 7 deletions lib/supervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void child_handler(int sig)

static void alarm_handler(int sig)
{
char *msg = mprintf("========= FAILED TIMEOUT %s in %lus\n",
char *msg = mprintf("========= FINISH { \"status\": \"failed\", \"duration\": %u }",
current_test ?: "(no test)", timeout);

if (write(childfd, msg, strlen(msg)) != strlen(msg))
Expand Down Expand Up @@ -217,7 +217,7 @@ static void test_start(char *new_test, struct timespec now)
current_test_start = now;
current_test_log = test_file_open("log");

write_test_file("status", "TEST FAILED\n");
write_test_file("status", "{ \"status\": \"failed\" }\n");

set_timeout(default_timeout);
}
Expand Down Expand Up @@ -349,13 +349,10 @@ int main(int argc, char *argv[])
test_end();
}

if (exit_on_failure && str_starts_with(line, "TEST FAILED"))
if (exit_on_failure && strstr(line, "failed"))
break;

if (exit_on_failure && strstr(line, "FAILED TIMEOUT"))
break;

if (exit_on_success && str_starts_with(line, "TEST SUCCESS")) {
if (exit_on_success && strstr(line, "success")) {
ret = 0;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/testrunner
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ check_taint()

if [[ $taint != 0 ]]; then
echo "Failure because kernel tainted - check log for warnings"
echo "TEST FAILED"
echo "========= FINISH { \"status\": \"failed\", }"
exit 0
fi
}
Expand Down

0 comments on commit da2e4b7

Please sign in to comment.