Skip to content

Commit 0ec6538

Browse files
committed
schlad is learning unit tests in perl
1 parent 97aed44 commit 0ec6538

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

t/30-test_parser.t

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,23 @@ subtest ktap_parse => sub {
984984
is $result3->result, 'skip', 'Group result is skipped';
985985
};
986986

987+
subtest 'ktap_parse_incorrect_file' => sub {
988+
my $ktap_file = path($FindBin::Bin, "data")->child("ktap_incorrect.tap");
989+
990+
my $parser = OpenQA::Parser::Format::KTAP->new;
991+
$parser->load($ktap_file);
992+
993+
is $parser->results->size, 3, 'Three test groups parsed (last one missing the final summary line)';
994+
995+
my $last = $parser->results->get(2);
996+
is $last->{name}, 'selftests: cgroup: test_zswap', 'Last test group name is correct';
997+
is scalar @{$last->details}, 7, 'Last group has 7 subtests';
998+
is $last->details->[0]->{title}, 'test_zswap_usage', 'First subtest parsed correctly';
999+
is $last->details->[-1]->{title}, 'test_no_invasive_cgroup_shrink', 'Last subtest parsed';
1000+
is $last->result, 'fail', 'Group result marked as fail (due to subtest failure)';
1001+
};
1002+
1003+
9871004
done_testing;
9881005

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

t/data/ktap_incorrect.tap

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 enabled
38+
# not ok 4 test_zswap_writeback_enabled
39+
# not ok 5 test_zswap_writeback_disabled
40+
# not ok 6 test_no_kmem_bypass
41+
# not ok 7 test_no_invasive_cgroup_shrink

0 commit comments

Comments
 (0)