Skip to content

Commit 3ddcc08

Browse files
committed
unit_tests: Add unit tests for KTAP parser
Two files with examplary output are added, one with version and plan and the other one without version. Examples contain the group of tests with pass, fail and skip statuses
1 parent 42286e3 commit 3ddcc08

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

t/30-test_parser.t

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use OpenQA::Parser::Format::LTP;
1616
use OpenQA::Parser::Format::XUnit;
1717
use OpenQA::Parser::Format::TAP;
1818
use OpenQA::Parser::Format::IPA;
19+
use OpenQA::Parser::Format::KTAP;
1920
use Mojo::File qw(path tempdir);
2021
use Mojo::JSON qw(decode_json encode_json);
2122

@@ -959,6 +960,30 @@ subtest nested_parsers => sub {
959960
test_ltp_file_v2($final_data->results->first);
960961
};
961962

963+
subtest ktap_parse => sub {
964+
965+
my $ktap_file = path($FindBin::Bin, "data")->child("ktap_correct.tap");
966+
967+
my $parser = OpenQA::Parser::Format::KTAP->new;
968+
$parser->load($ktap_file);
969+
970+
is $parser->results->size, 4, 'Expected four test groups';
971+
972+
my $result0 = $parser->results->get(0);
973+
is $result0->{name}, 'selftests: cgroup: test_core', 'The first test group has expected name';
974+
975+
is $result0->result, 'passed', 'Group result is passed';
976+
is scalar @{$result0->details}, 12, 'Has 12 subtest details';
977+
is $result0->details->[0]->{result}, 'ok', 'First subtest passed';
978+
is $result0->details->[0]->{title}, 'test_cgcore_internal_process_constraint', 'First subtest has expected name';
979+
980+
my $result2 = $parser->results->get(2);
981+
is $result2->result, 'fail', 'Group result is failed';
982+
983+
my $result3 = $parser->results->get(3);
984+
is $result3->result, 'skip', 'Group result is skipped';
985+
};
986+
962987
done_testing;
963988

964989
package OpenQA::Parser::Format::Dummy { # uncoverable statement

t/data/ktap_correct.tap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
TAP version 13
2+
1..13
3+
# overriding timeout to 300
4+
# selftests: cgroup: test_core
5+
# ok 1 test_cgcore_internal_process_constraint
6+
# ok 2 test_cgcore_top_down_constraint_enable
7+
# ok 3 test_cgcore_top_down_constraint_disable
8+
# ok 4 test_cgcore_no_internal_process_constraint_on_threads
9+
# ok 5 test_cgcore_parent_becomes_threaded
10+
# ok 6 test_cgcore_invalid_domain
11+
# ok 7 test_cgcore_populated
12+
# ok 8 test_cgcore_proc_migration
13+
# ok 9 test_cgcore_thread_migration
14+
# ok 10 test_cgcore_destroy
15+
# ok 11 test_cgcore_lesser_euid_open
16+
# ok 12 test_cgcore_lesser_ns_open
17+
ok 1 selftests: cgroup: test_core
18+
# overriding timeout to 300
19+
# selftests: cgroup: test_cpu
20+
# ok 1 test_cpucg_subtree_control
21+
# ok 2 test_cpucg_stats
22+
# ok 3 test_cpucg_nice
23+
# ok 4 test_cpucg_weight_overprovisioned
24+
# ok 5 test_cpucg_weight_underprovisioned
25+
# ok 6 test_cpucg_nested_weight_overprovisioned
26+
# ok 7 test_cpucg_nested_weight_underprovisioned
27+
# ok 8 test_cpucg_max
28+
# ok 9 test_cpucg_max_nested
29+
ok 2 selftests: cgroup: test_cpu
30+
# overriding timeout to 300
31+
# selftests: cgroup: test_zswap
32+
# # zswpout does not increase after test program
33+
# not ok 1 test_zswap_usage
34+
# ok 2 test_swapin_nozswap
35+
# # at least 24MB should be brought back from zswap
36+
# not ok 3 test_zswapin
37+
# # zswpwb_after is 0 while wb is enablednot ok 4 test_zswap_writeback_enabled
38+
# not ok 5 test_zswap_writeback_disabled
39+
# not ok 6 test_no_kmem_bypass
40+
# not ok 7 test_no_invasive_cgroup_shrink
41+
not ok 10 selftests: cgroup: test_zswap # exit=1
42+
# overriding timeout to 300
43+
# selftests: cgroup: test_hugetlb_memcg
44+
# 1..0 # SKIP memory hugetlb accounting is disabled
45+
ok 5 selftests: cgroup: test_hugetlb_memcg # SKIP

0 commit comments

Comments
 (0)