Skip to content

Commit f980559

Browse files
committed
Replace all remaining trivial true/true assertions across 25 test files
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent 228386f commit f980559

25 files changed

Lines changed: 68 additions & 77 deletions

tests/test_address_of_user_types.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let test_address_of_user_type_resolution () =
4848
let ast = Kernelscript.Parse.parse_string code in
4949
let symbol_table = Test_utils.Helpers.create_test_symbol_table ~include_xdp:true ast in
5050
let (_, _) = Kernelscript.Type_checker.type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
51-
check bool "Address-of user type resolution test passed" true true
51+
()
5252
with
5353
| Type_error (msg, _) ->
5454
Alcotest.fail ("Type error should not occur: " ^ msg)
@@ -91,7 +91,7 @@ let test_address_of_nested_user_types () =
9191
let ast = Kernelscript.Parse.parse_string code in
9292
let symbol_table = Test_utils.Helpers.create_test_symbol_table ~include_xdp:true ast in
9393
let (_, _) = Kernelscript.Type_checker.type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
94-
check bool "Nested address-of user type resolution test passed" true true
94+
()
9595
with
9696
| Type_error (msg, _) ->
9797
Alcotest.fail ("Type error should not occur: " ^ msg)

tests/test_array_init.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ let test_semantic_analysis () =
139139
("var arr: bool[2] = [true]", "Boolean fill should work");
140140
] in
141141

142-
List.iter (fun (input, description) ->
142+
List.iter (fun (input, _description) ->
143143
let program_text = Printf.sprintf {|
144144
@xdp fn test(ctx: *xdp_md) -> xdp_action {
145145
%s
@@ -150,7 +150,7 @@ let test_semantic_analysis () =
150150
let ast = Kernelscript.Parse.parse_string program_text in
151151
let symbol_table = Kernelscript.Symbol_table.build_symbol_table ast in
152152
let (_typed_ast, _) = Kernelscript.Type_checker.type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
153-
check bool description true true
153+
()
154154
with
155155
| e -> fail ("Semantic analysis failed for " ^ input ^ ": " ^ Printexc.to_string e)
156156
) test_cases
@@ -162,7 +162,7 @@ let test_error_cases () =
162162
("var arr: u32[4] = [1, true, 3]", "Array elements must have consistent type");
163163
] in
164164

165-
List.iter (fun (input, expected_error) ->
165+
List.iter (fun (input, _expected_error) ->
166166
let program_text = Printf.sprintf {|
167167
@xdp fn test(ctx: *xdp_md) -> xdp_action {
168168
%s
@@ -175,7 +175,7 @@ let test_error_cases () =
175175
let (_typed_ast, _) = Kernelscript.Type_checker.type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
176176
fail ("Expected error for " ^ input ^ " but compilation succeeded")
177177
with
178-
| _ -> check bool expected_error true true
178+
| _ -> ()
179179
) test_cases
180180

181181
let () =

tests/test_btf_binary_parser.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ let test_btf_array_type_resolution () =
184184
);
185185

186186
(* Verify that the function interface works correctly *)
187-
check bool "BTF parser handles invalid input gracefully" true true
187+
()
188188
in
189189

190190
test_array_scenario ()
@@ -206,11 +206,7 @@ let test_btf_kind_coverage () =
206206
*)
207207

208208
(* Verify that these improvements compiled and are available *)
209-
check bool "BTF kind coverage includes arrays" true true;
210-
check bool "BTF kind coverage includes forward declarations" true true;
211-
check bool "BTF kind coverage includes float types" true true;
212-
check bool "BTF kind coverage includes variables" true true;
213-
check bool "BTF kind coverage includes data sections" true true;
209+
();
214210
in
215211

216212
test_kind_scenarios ()

tests/test_comment_positions.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let test_comment_at_start () =
2727
try
2828
let ast = parse_string program_text in
2929
check int "AST declarations count" 1 (List.length ast);
30-
check bool "comment at start parsing" true true
30+
()
3131
with
3232
| Parse_error (msg, pos) ->
3333
fail ("Parse error: " ^ msg ^ " at " ^ string_of_position pos)
@@ -41,7 +41,7 @@ let test_comment_with_whitespace () =
4141
try
4242
let ast = parse_string program_text in
4343
check int "AST declarations count" 1 (List.length ast);
44-
check bool "comment with whitespace parsing" true true
44+
()
4545
with
4646
| Parse_error (msg, pos) ->
4747
fail ("Parse error: " ^ msg ^ " at " ^ string_of_position pos)
@@ -83,7 +83,7 @@ let test_multiple_line_comments () =
8383
try
8484
let ast = parse_string program_text in
8585
check int "AST declarations count" 1 (List.length ast);
86-
check bool "multiple line comments parsing" true true
86+
()
8787
with
8888
| Parse_error (msg, pos) ->
8989
fail ("Parse error: " ^ msg ^ " at " ^ string_of_position pos)
@@ -96,7 +96,7 @@ let test_inline_comments () =
9696
try
9797
let ast = parse_string program_text in
9898
check int "AST declarations count" 1 (List.length ast);
99-
check bool "inline comments parsing" true true
99+
()
100100
with
101101
| Parse_error (msg, pos) ->
102102
fail ("Parse error: " ^ msg ^ " at " ^ string_of_position pos)

tests/test_config_struct_generation.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fn main() -> i32 {
311311
let ast = parse_string program_text in
312312
let _ = build_symbol_table ast in
313313
let _ = type_check_and_annotate_ast ast in
314-
check bool "config field reads allowed in eBPF" true true
314+
()
315315
with
316316
| e -> fail ("Unexpected error in config read test: " ^ Printexc.to_string e)
317317

tests/test_detach_api.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ fn main() -> i32 {
143143
with
144144
| Type_error (_, _) ->
145145
(* Expected type error *)
146-
check bool "Got expected type error" true true
146+
()
147147
| Failure msg when string_contains_substring msg "type" ->
148148
(* Expected type error as Failure *)
149-
check bool "Got expected type error" true true
149+
()
150150
| _ -> (fail "Should have failed with type error" : unit)
151151

152152
(* Test suite definition *)

tests/test_dynptr_bridge.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ let test_memory_bridge_integration () =
5555
| Some info ->
5656
(match info.Kernelscript.Ebpf_c_codegen.region_type with
5757
| Kernelscript.Ebpf_c_codegen.PacketData ->
58-
check bool (test_name ^ " - packet_ptr has PacketData region") true true
58+
()
5959
| Kernelscript.Ebpf_c_codegen.LocalStack ->
60-
check bool (test_name ^ " - packet_ptr has LocalStack region (expected for variable allocation)") true true
60+
()
6161
| _ ->
6262
let region_str = match info.Kernelscript.Ebpf_c_codegen.region_type with
6363
| Kernelscript.Ebpf_c_codegen.PacketData -> "PacketData"

tests/test_enum.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ let test_enum_edge_cases () =
222222
with
223223
| Symbol_error _ ->
224224
(* If it fails, that's also acceptable behavior *)
225-
check bool "duplicate rejected" true true
225+
()
226226

227227
(** Test enum with large values *)
228228
let test_enum_large_values () =
@@ -370,7 +370,7 @@ let test_enum_not_numeric_literals () =
370370
(* Verify it's NOT IRLiteral *)
371371
(match ir_value.value_desc with
372372
| IRLiteral _ -> check bool "should not be IRLiteral" false true
373-
| IREnumConstant _ -> check bool "correctly preserved as IREnumConstant" true true
373+
| IREnumConstant _ -> ()
374374
| _ -> check bool "unexpected IR value type" false true)
375375

376376
(** Test complete enum preservation pipeline *)
@@ -580,14 +580,14 @@ let test_enum_array_index () =
580580
let _typed_ast = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
581581

582582
(* If we reach here, type checking succeeded *)
583-
check bool "enum array index type checking passes" true true
583+
()
584584
with
585585
| Type_error (msg, _) when String.contains msg 'A' && String.contains msg 'r' ->
586586
(* If we get "Array index must be integer type" error, the test fails *)
587587
check bool ("enum array index should be allowed: " ^ msg) false true
588588
| Type_error (_, _) ->
589589
(* Other type errors are acceptable for this test *)
590-
check bool "enum array index type checking passes" true true
590+
()
591591
| Parse_error (msg, _) ->
592592
check bool ("parse error: " ^ msg) false true
593593
| e ->

tests/test_evaluator.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let test_basic_evaluation () =
3333
try
3434
let ast = parse_string program_text in
3535
let _ = List.length ast in
36-
check bool "basic evaluation test" true true
36+
check bool "basic evaluation test" true (List.length ast > 0)
3737
with
3838
| _ -> fail "Failed basic evaluation test"
3939

@@ -70,7 +70,7 @@ let test_enum_constant_evaluation () =
7070

7171
match eval_expression eval_ctx xdp_pass_expr with
7272
| EnumValue ("xdp_action", 2L) ->
73-
check bool "XDP_PASS correctly evaluated from symbol table" true true
73+
()
7474
| _ ->
7575
fail "XDP_PASS should evaluate to EnumValue(xdp_action, 2)"
7676
with
@@ -99,15 +99,15 @@ let test_various_enum_constants () =
9999
let xdp_drop_expr = make_test_expr (Kernelscript.Ast.Identifier "XDP_DROP") in
100100
(match eval_expression eval_ctx xdp_drop_expr with
101101
| EnumValue ("xdp_action", 1L) ->
102-
check bool "XDP_DROP correctly evaluated" true true
102+
()
103103
| _ ->
104104
fail "XDP_DROP should evaluate to EnumValue(xdp_action, 1)");
105105

106106
(* Test TC enum constant *)
107107
let tc_ok_expr = make_test_expr (Kernelscript.Ast.Identifier "TC_ACT_OK") in
108108
(match eval_expression eval_ctx tc_ok_expr with
109109
| EnumValue ("tc_action", 0L) ->
110-
check bool "TC_ACT_OK correctly evaluated" true true
110+
()
111111
| _ ->
112112
fail "TC_ACT_OK should evaluate to EnumValue(tc_action, 0)")
113113
with

tests/test_function_validation.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn main() -> i32 {
8989
let ast = parse_string program_text in
9090
let _ = build_symbol_table ast in
9191
let (_, _) = type_check_and_annotate_ast ast in
92-
check bool "proper eBPF function names should be accepted" true true
92+
()
9393
with
9494
| _ ->
9595
check bool "proper eBPF function names rejected unexpectedly" false true
@@ -109,7 +109,7 @@ fn main() -> i32 {
109109
let ast = parse_string program_text in
110110
let _ = build_symbol_table ast in
111111
let (_, _) = type_check_and_annotate_ast ast in
112-
check bool "userspace main function should be accepted" true true
112+
()
113113
with
114114
| _ ->
115115
check bool "userspace main function rejected unexpectedly" false true

0 commit comments

Comments
 (0)