FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
kernelscript/tests/test_type_checker.ml at main · multikernel/kernelscript · GitHub
multikernel
/
kernelscript
Public
Notifications
You must be signed in to change notification settings
Fork
24
Star
508
Code
Issues
2
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
kernelscript
/
tests
/
test_type_checker.ml
Copy path
More file actions
More file actions
Latest commit
History
History
History
1300 lines (1150 loc) · 46.3 KB
Breadcrumbs
kernelscript
/
tests
/
test_type_checker.ml
Copy path
File metadata and controls
1300 lines (1150 loc) · 46.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*
* Copyright 2025 Multikernel Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*)
open
Kernelscript.Ast
open
Kernelscript.Type_checker
open
Kernelscript.Parse
open
Alcotest
(*
* Helper function to parse string with builtin types loaded via symbol table
*)
let
parse_string_with_builtins
code
=
let
ast
=
parse_string code
in
(*
Create symbol table with test builtin types
*)
let
symbol_table
=
Test_utils.Helpers.
create_test_symbol_table ast
in
(*
Run type checking with builtin types loaded
*)
let
(typed_ast, _)
=
Kernelscript.Type_checker.
type_check_and_annotate_ast
~symbol_table:
(
Some
symbol_table) ast
in
typed_ast
(*
* Helper function to create symbol table with builtin loading
*)
let
create_symbol_table_with_builtins
ast
=
Test_utils.Helpers.
create_test_symbol_table ast
(*
* Helper function to type check with builtin types loaded
*)
let
type_check_and_annotate_ast_with_builtins
ast
=
(*
Create symbol table with test builtin types
*)
let
symbol_table
=
Test_utils.Helpers.
create_test_symbol_table ast
in
(*
Run type checking with builtin types loaded
*)
Kernelscript.Type_checker.
type_check_and_annotate_ast
~symbol_table:
(
Some
symbol_table) ast
(*
* Helper function to check if two types can unify
*)
let
can_unify
t1
t2
=
match
unify_types t1 t2
with
|
Some
_
->
true
|
None
->
false
(*
* Test type unification
*)
let
test_type_unification
()
=
(*
Test basic type unification
*)
check
bool
"
U32 unifies with U32
"
true
(can_unify
U32
U32
);
check
bool
"
U32 can unify with U64 (promotion)
"
true
(can_unify
U32
U64
);
check
bool
"
Pointer U8 unifies with Pointer U8
"
true
(can_unify (
Pointer
U8
) (
Pointer
U8
));
check
bool
"
Array types unify
"
true
(can_unify (
Array
(
U32
,
10
)) (
Array
(
U32
,
10
)));
check
bool
"
Different array sizes don't unify
"
false
(can_unify (
Array
(
U32
,
10
)) (
Array
(
U32
,
20
)))
(*
* Test basic type inference
*)
let
test_basic_type_inference
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var x
=
42
var y
=
true
var z
=
"
hello
"
return
2
}
|
}
in
try
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed programs count
"
1
(
List.
length typed_attributed_functions);
(*
Verify that type checking completed without errors
*)
match
List.
hd typed_attributed_functions
with
|
(
attr_list
,
typed_func
) ->
check
string
"
program name
"
"
test
"
typed_func.tfunc_name;
check
int
"
function parameters
"
1
(
List.
length typed_func.tfunc_params);
check
bool
"
has xdp attribute
"
true
(
List.
exists (
function
SimpleAttribute
"xdp"
->
true
|
_
->
false
) attr_list)
with
|
_
-> fail
"
Error occurred
"
(*
* Test variable type checking
*)
let
test_variable_type_checking
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
x
:
u32
=
42
var
y
:
bool
=
true
var
z
=
x
+
10
return
2
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
1
(
List.
length typed_attributed_functions);
let
(_attrs, typed_func)
=
List.
hd typed_attributed_functions
in
check
string
"
function name
"
"
test
"
typed_func.tfunc_name;
check
int
"
body has 4 statements
"
4
(
List.
length typed_func.tfunc_body)
(*
* Test binary operations
*)
let
test_binary_operations
()
=
let
valid_operations
=
[
(
"
var x = 1 + 2
"
,
true
);
(
"
var x = 1 - 2
"
,
true
);
(
"
var x = 1 * 2
"
,
true
);
(
"
var x = 1 / 2
"
,
true
);
(
"
var x = 1 == 2
"
,
true
);
(
"
var x = 1 != 2
"
,
true
);
(
"
var x = 1 < 2
"
,
true
);
(
"
var x = true && false
"
,
true
);
(
"
var x = true || false
"
,
true
);
]
in
List.
iter (
fun
(
stmt
,
should_succeed
) ->
let
program_text
=
Printf.
sprintf {
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
%
s
return
0
}
|
} stmt
in
try
let
ast
=
parse_string program_text
in
let
_
=
type_check_and_annotate_ast_with_builtins ast
in
check
bool
(
"
binary operation:
"
^
stmt) should_succeed
true
with
|
_
-> check
bool
(
"
binary operation:
"
^
stmt) should_succeed
false
) valid_operations
(*
* Test function calls
*)
let
test_function_calls
()
=
let
program_text
=
{
|
@
helper
fn helper(x:
u32, y: u32
) -> u32 {
return x
+
y
}
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var result
=
helper(
10
,
20
)
return result
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
2
(
List.
length typed_attributed_functions);
let
helper_func
=
List.
find (
fun
(
_
,
tf
) -> tf.tfunc_name
=
"
helper
"
) typed_attributed_functions
in
let
(_, helper_tf)
=
helper_func
in
check
int
"
helper params
"
2
(
List.
length helper_tf.tfunc_params);
check
string
"
helper return type
"
"
u32
"
(
Kernelscript.Ast.
string_of_bpf_type helper_tf.tfunc_return_type)
(*
* Test context types
*)
let
test_context_types
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
return
2
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
1
(
List.
length typed_attributed_functions);
let
(_attrs, typed_func)
=
List.
hd typed_attributed_functions
in
check
string
"
function name
"
"
test
"
typed_func.tfunc_name;
check
int
"
param count
"
1
(
List.
length typed_func.tfunc_params);
let
(param_name, param_type)
=
List.
hd typed_func.tfunc_params
in
check
string
"
context param name
"
"
ctx
"
param_name;
check
string
"
context param type
"
"
*xdp_md
"
(
Kernelscript.Ast.
string_of_bpf_type param_type)
(*
* Test struct field access
*)
let
test_struct_field_access
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var packet
=
ctx->data
return
0
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
1
(
List.
length typed_attributed_functions);
let
(_attrs, typed_func)
=
List.
hd typed_attributed_functions
in
check
int
"
body has 2 statements
"
2
(
List.
length typed_func.tfunc_body)
(*
* Test statement type checking
*)
let
test_statement_type_checking
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
x
:
u32
=
42
x
=
50
if
(
x
>
0
) {
return
1
}
return
0
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
1
(
List.
length typed_attributed_functions);
let
(_attrs, typed_func)
=
List.
hd typed_attributed_functions
in
check
string
"
function name
"
"
test
"
typed_func.tfunc_name;
check
int
"
body has 4 statements
"
4
(
List.
length typed_func.tfunc_body)
(*
* Test function type checking
*)
let
test_function_type_checking
()
=
let
program_text
=
{
|
@
helper
fn calculate(a:
u32, b: u32
) -> u32 {
var result
=
a
+
b
return result
}
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var value
=
calculate(
10
,
20
)
return value
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
2
(
List.
length typed_attributed_functions);
let
calc_func
=
List.
find (
fun
(
_
,
tf
) -> tf.tfunc_name
=
"
calculate
"
) typed_attributed_functions
in
let
(_, calc_tf)
=
calc_func
in
check
int
"
calculate params
"
2
(
List.
length calc_tf.tfunc_params);
check
string
"
calculate return type
"
"
u32
"
(
Kernelscript.Ast.
string_of_bpf_type calc_tf.tfunc_return_type)
(*
* Test built-in function type checking
*)
let
test_builtin_function_type_checking
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
print(
"
Hello from eBPF
"
)
print(
"
Message with value:
"
,
42
)
print
()
return
0
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
1
(
List.
length typed_attributed_functions);
let
(_attrs, typed_func)
=
List.
hd typed_attributed_functions
in
check
int
"
body has 4 statements (3 print + 1 return)
"
4
(
List.
length typed_func.tfunc_body)
(*
* Test variadic function argument handling
*)
let
test_variadic_function_arguments
()
=
let
test_cases
=
[
(
"
print()
"
,
true
,
"
no arguments
"
);
(
"
print(
\"
hello
\"
)
"
,
true
,
"
single string argument
"
);
(
"
print(
\"
value:
\"
, 42)
"
,
true
,
"
string and number
"
);
(
"
print(
\"
a
\"
,
\"
b
\"
,
\"
c
\"
)
"
,
true
,
"
multiple arguments
"
);
(
"
print(1, 2, 3, 4, 5)
"
,
true
,
"
many arguments
"
);
]
in
List.
iter (
fun
(
call
,
should_succeed
,
desc
) ->
let
program_text
=
Printf.
sprintf {
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
%
s
return
0
}
|
} call
in
try
let
ast
=
parse_string program_text
in
let
_
=
type_check_and_annotate_ast_with_builtins ast
in
check
bool
(
"
variadic function:
"
^
desc) should_succeed
true
with
|
_
-> check
bool
(
"
variadic function:
"
^
desc) should_succeed
false
) test_cases
(*
* Test built-in function return types
*)
let
test_builtin_function_return_types
()
=
let
program_text
=
{
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
result
:
u32
=
print
(
"test message"
)
return
result
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
1
(
List.
length typed_attributed_functions);
let
(_attrs, typed_func)
=
List.
hd typed_attributed_functions
in
check
int
"
body has 2 statements
"
2
(
List.
length typed_func.tfunc_body)
(*
* Test built-in vs user-defined function precedence
*)
let
test_builtin_vs_user_function_precedence
()
=
let
program_text
=
{
|
@
helper
fn my_function(x:
u32
) -> u32 {
return x
+
1
}
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var user_result
=
my_function(
10
)
print(
"
User function result:
"
, user_result)
return user_result
}
|
}
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
typed functions count
"
2
(
List.
length typed_attributed_functions);
let
my_func
=
List.
find (
fun
(
_
,
tf
) -> tf.tfunc_name
=
"
my_function
"
) typed_attributed_functions
in
let
(_, my_tf)
=
my_func
in
check
string
"
user function return type
"
"
u32
"
(
Kernelscript.Ast.
string_of_bpf_type my_tf.tfunc_return_type)
(*
* Test stdlib integration
*)
let
test_stdlib_integration
()
=
(*
Test that stdlib functions are properly recognized
*)
check
bool
"
print is builtin
"
true
(
Kernelscript.Stdlib.
is_builtin_function
"
print
"
);
check
bool
"
non_existent is not builtin
"
false
(
Kernelscript.Stdlib.
is_builtin_function
"
non_existent_function
"
);
(*
Test getting function signature
*)
(
match
Kernelscript.Stdlib.
get_builtin_function_signature
"
print
"
with
|
Some
(
params
,
return_type
) ->
check
int
"
print parameter count
"
0
(
List.
length params);
check
bool
"
print return type is U32
"
true
(return_type
=
Kernelscript.Ast.
U32
)
|
None
-> check
bool
"
print function signature should exist
"
false
true
);
(*
Test context-specific implementations
*)
(
match
Kernelscript.Stdlib.
get_ebpf_implementation
"
print
"
with
|
Some
impl
-> check
string
"
eBPF implementation
"
"
bpf_printk
"
impl
|
None
-> check
bool
"
eBPF implementation should exist
"
false
true
);
(
match
Kernelscript.Stdlib.
get_userspace_implementation
"
print
"
with
|
Some
impl
-> check
string
"
userspace implementation
"
"
printf
"
impl
|
None
-> check
bool
"
userspace implementation should exist
"
false
true
)
(*
* Test error handling
*)
let
test_error_handling
()
=
let
invalid_programs
=
[
(
"
var x: u32 = true
"
,
"
type mismatch
"
);
(
"
var x = 1 + true
"
,
"
invalid binary operation
"
);
(
"
var x = unknown_var
"
,
"
undefined variable
"
);
(
"
var x = func_not_exists()
"
,
"
undefined function
"
);
]
in
List.
iter (
fun
(
stmt
,
description
) ->
let
program_text
=
Printf.
sprintf {
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
%
s
return
2
//
XDP_PASS
}
|
} stmt
in
try
let
ast
=
parse_string program_text
in
let
_
=
type_check_and_annotate_ast_with_builtins ast
in
fail (
"
Should have failed for:
"
^
description)
with
|
Type_error
(
msg
,
_
) ->
check
bool
(
"
error handling got Type_error:
"
^
description)
true
(
String.
length msg
>
0
)
|
Kernelscript.Symbol_table.
Symbol_error
(
msg
,
_
) ->
check
bool
(
"
error handling got Symbol_error:
"
^
description)
true
(
String.
length msg
>
0
)
|
Failure
msg
->
check
bool
(
"
error handling got Failure:
"
^
description)
true
(
String.
length msg
>
0
)
) invalid_programs
(*
* Test program type checking
*)
let
test_program_type_checking
()
=
let
program_text
=
{
|
@
helper
fn is_tcp(protocol:
u8
) ->
bool
{
return protocol
==
6
}
@
xdp fn packet_filter(ctx:
*xdp_md
) -> xdp_action {
var
protocol
:
u8
=
6
if
(
is_tcp
(
protocol
)) {
return
2
//
2
//
XDP_PASS
}
return
1
//
1
//
XDP_DROP
}
|
}
in
try
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
program type checking
"
2
(
List.
length typed_attributed_functions);
(*
Verify that type checking completed without errors
*)
(*
Find the XDP attributed function
*)
let
xdp_func
=
List.
find (
fun
(
attr_list
,
_
) ->
List.
exists (
function
SimpleAttribute
"xdp"
->
true
|
_
->
false
) attr_list
) typed_attributed_functions
in
match
xdp_func
with
|
(
attr_list
,
typed_func
) ->
check
string
"
typed program name
"
"
packet_filter
"
typed_func.tfunc_name;
check
int
"
typed function parameters
"
1
(
List.
length typed_func.tfunc_params);
check
bool
"
has xdp attribute
"
true
(
List.
exists (
function
SimpleAttribute
"xdp"
->
true
|
_
->
false
) attr_list)
with
|
_
-> fail
"
Error occurred
"
(*
* Test integer type promotion
*)
let
test_integer_type_promotion
()
=
let
program_text
=
{
|
var
counter
:
hash
<
u32,
u64
>
(
1024
)
@
xdp
fn
test_promotion
(
ctx
:
*
xdp_md) ->
xdp_action
{
//
Test
U32
literal assignment
to
U64
map value
counter[
1
]
=
100
//
U32
literal should promote
to
U64
counter[
2
]
=
200
//
U32
literal should promote
to
U64
//
Test
arithmetic
with
different sizes
var
small
:
u32
=
50
var
large
:
u64
=
1000
var
result
=
small
+
large
//
U32
should
promote
to
U64
//
Test
map
access
with
promoted
values
var
val1
=
counter
[
1
]
+
50
//
U64
+
U32
->
U64
counter
[
3
]
=
val1
return
XDP_PASS
}
|}
in
try
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
type promotion programs count
"
1
(
List.
length typed_attributed_functions);
let
xdp_func
=
List.
find (
fun
(
_
,
tf
) -> tf.tfunc_name
=
"
test_promotion
"
) typed_attributed_functions
in
let
(_, typed_func)
=
xdp_func
in
check
string
"
type promotion program name
"
"
test_promotion
"
typed_func.tfunc_name;
check
int
"
body statements
"
8
(
List.
length typed_func.tfunc_body)
with
|
exn
->
Printf.
printf
"
Error in integer type promotion test: %s
\n
"
(
Printexc.
to_string
exn
);
fail
"
Error occurred in type promotion test
"
(*
* Test type unification enhancements
*)
let
test_type_unification_enhanced
()
=
(*
Test the specific type promotions we added
*)
check
bool
"
U32 promotes to U64
"
true
(can_unify
U32
U64
);
check
bool
"
U64 unifies with U32
"
true
(can_unify
U64
U32
);
check
bool
"
I32 promotes to I64
"
true
(can_unify
I32
I64
);
check
bool
"
I64 unifies with I32
"
true
(can_unify
I64
I32
);
check
bool
"
U16 promotes to U64
"
true
(can_unify
U16
U64
);
check
bool
"
U8 promotes to U64
"
true
(can_unify
U8
U64
);
(*
Test that incompatible types still don't unify
*)
check
bool
"
U32 does not unify with Bool
"
false
(can_unify
U32
Bool
);
(*
I32 and U32 should now unify due to permissive integer literal behavior
*)
check
bool
"
I32 unifies with U32
"
true
(can_unify
I32
U32
)
(*
* Test comprehensive type checking
*)
let
test_comprehensive_type_checking
()
=
let
program_text
=
{
|
var
counter
:
hash
<
u32,
u64
>
(
1024
)
@
helper
fn
increment_counter
(
key
:
u32
) ->
u64
{
var current
=
counter[key]
var new_value
=
current
+
1
counter[key]
=
new_value
return new_value
}
@
helper
fn
process_packet
(
size
:
u32
) ->
bool
{
return size
>
1500
}
@
xdp
fn
comprehensive_test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var
packet_size
:
u32
=
1000
var
counter_val
=
increment_counter
(
packet_size
)
var
is_large
=
process_packet
(
packet_size
)
if
(
is_large
&&
counter_val
>
100
) {
return
XDP_DROP
}
else
{
return
XDP_PASS
}
}
|}
in
try
let
ast
=
parse_string_with_builtins program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
"
comprehensive AST length
"
3
(
List.
length typed_attributed_functions);
(*
Verify that type checking completed without errors
*)
(*
Find the XDP attributed function
*)
let
xdp_func
=
List.
find (
fun
(
attr_list
,
_
) ->
List.
exists (
function
SimpleAttribute
"xdp"
->
true
|
_
->
false
) attr_list
) typed_attributed_functions
in
match
xdp_func
with
|
(
attr_list
,
typed_func
) ->
check
string
"
comprehensive program name
"
"
comprehensive_test
"
typed_func.tfunc_name;
check
int
"
comprehensive function parameters
"
1
(
List.
length typed_func.tfunc_params);
check
bool
"
has xdp attribute
"
true
(
List.
exists (
function
SimpleAttribute
"xdp"
->
true
|
_
->
false
) attr_list)
with
|
_
-> fail
"
Error occurred
"
(*
* Test comprehensive integer promotion
*)
let
test_comprehensive_integer_promotion
()
=
(*
Test all integer promotion combinations
*)
let
promotion_tests
=
[
(*
U8 promotions
*)
(
U8
,
U16
,
"
U8 promotes to U16
"
);
(
U8
,
U32
,
"
U8 promotes to U32
"
);
(
U8
,
U64
,
"
U8 promotes to U64
"
);
(
U16
,
U8
,
"
U16 promotes to U16 (reverse)
"
);
(
U32
,
U8
,
"
U32 promotes to U32 (reverse)
"
);
(
U64
,
U8
,
"
U64 promotes to U64 (reverse)
"
);
(*
U16 promotions
*)
(
U16
,
U32
,
"
U16 promotes to U32
"
);
(
U16
,
U64
,
"
U16 promotes to U64
"
);
(
U32
,
U16
,
"
U32 promotes to U32 (reverse)
"
);
(
U64
,
U16
,
"
U64 promotes to U64 (reverse)
"
);
(*
U32 promotions
*)
(
U32
,
U64
,
"
U32 promotes to U64
"
);
(
U64
,
U32
,
"
U64 promotes to U64 (reverse)
"
);
(*
I8 promotions
*)
(
I8
,
I16
,
"
I8 promotes to I16
"
);
(
I8
,
I32
,
"
I8 promotes to I32
"
);
(
I8
,
I64
,
"
I8 promotes to I64
"
);
(
I16
,
I8
,
"
I16 promotes to I16 (reverse)
"
);
(
I32
,
I8
,
"
I32 promotes to I32 (reverse)
"
);
(
I64
,
I8
,
"
I64 promotes to I64 (reverse)
"
);
(*
I16 promotions
*)
(
I16
,
I32
,
"
I16 promotes to I32
"
);
(
I16
,
I64
,
"
I16 promotes to I64
"
);
(
I32
,
I16
,
"
I32 promotes to I32 (reverse)
"
);
(
I64
,
I16
,
"
I64 promotes to I64 (reverse)
"
);
(*
I32 promotions
*)
(
I32
,
I64
,
"
I32 promotes to I64
"
);
(
I64
,
I32
,
"
I64 promotes to I64 (reverse)
"
);
]
in
List.
iter (
fun
(
t1
,
t2
,
desc
) ->
check
bool
desc
true
(can_unify t1 t2)
) promotion_tests;
(*
Test that incompatible types still don't unify
*)
let
incompatible_tests
=
[
(
U8
,
Bool
,
"
U8 does not unify with Bool
"
);
(
I16
,
Str
32
,
"
I16 does not unify with Str
"
);
(
U32
,
Pointer
U32
,
"
U32 does not unify with Pointer U32
"
);
]
in
List.
iter (
fun
(
t1
,
t2
,
desc
) ->
check
bool
desc
false
(can_unify t1 t2)
) incompatible_tests;
(*
Test that compatible integer types do unify (permissive behavior)
*)
let
compatible_tests
=
[
(
U32
,
I32
,
"
U32 unifies with I32
"
);
(
U64
,
I64
,
"
U64 unifies with I64
"
);
(
I32
,
U32
,
"
I32 unifies with U32
"
);
(
I64
,
U64
,
"
I64 unifies with U64
"
);
]
in
List.
iter (
fun
(
t1
,
t2
,
desc
) ->
check
bool
desc
true
(can_unify t1 t2)
) compatible_tests
(*
* Test arithmetic operations with integer promotion
*)
let
test_arithmetic_promotion
()
=
let
arithmetic_tests
=
[
(*
Basic arithmetic with different sizes
*)
(
"
var x: u8 = 10
\n
var y: u64 = 1000
\n
var result = x + y
"
,
"
u8 + u64 addition
"
);
(
"
var x: u16 = 100
\n
var y: u32 = 2000
\n
var result = x * y
"
,
"
u16 * u32 multiplication
"
);
(
"
var x: u32 = 500
\n
var y: u64 = 1000
\n
var result = y - x
"
,
"
u64 - u32 subtraction
"
);
(
"
var x: u8 = 5
\n
var y: u16 = 10
\n
var result = x / y
"
,
"
u8 / u16 division
"
);
(
"
var x: u16 = 17
\n
var y: u32 = 5
\n
var result = x % y
"
,
"
u16 % u32 modulo
"
);
(*
Signed arithmetic
*)
(
"
var x: i8 = -10
\n
var y: i64 = 1000
\n
var result = x + y
"
,
"
i8 + i64 addition
"
);
(
"
var x: i16 = -100
\n
var y: i32 = 2000
\n
var result = x * y
"
,
"
i16 * i32 multiplication
"
);
(
"
var x: i32 = -500
\n
var y: i64 = 1000
\n
var result = y - x
"
,
"
i64 - i32 subtraction
"
);
]
in
List.
iter (
fun
(
stmt
,
desc
) ->
let
program_text
=
Printf.
sprintf {
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
%
s
return
2
//
XDP_PASS
}
|
} stmt
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
(
"
arithmetic promotion func count:
"
^
desc)
1
(
List.
length typed_attributed_functions);
let
(_, tf)
=
List.
hd typed_attributed_functions
in
check
string
(
"
arithmetic promotion func name:
"
^
desc)
"
test
"
tf.tfunc_name
) arithmetic_tests
(*
* Test comparison operations with integer promotion
*)
let
test_comparison_promotion
()
=
let
comparison_tests
=
[
(*
Equality comparisons
*)
(
"
var x: u8 = 10
\n
var y: u64 = 10
\n
var result = x == y
"
,
"
u8 == u64 equality
"
);
(
"
var x: u16 = 100
\n
var y: u32 = 200
\n
var result = x != y
"
,
"
u16 != u32 inequality
"
);
(
"
var x: i8 = -5
\n
var y: i64 = -5
\n
var result = x == y
"
,
"
i8 == i64 equality
"
);
(*
Ordering comparisons
*)
(
"
var x: u8 = 10
\n
var y: u64 = 100
\n
var result = x < y
"
,
"
u8 < u64 less than
"
);
(
"
var x: u16 = 1000
\n
var y: u32 = 500
\n
var result = x > y
"
,
"
u16 > u32 greater than
"
);
(
"
var x: u32 = 100
\n
var y: u64 = 100
\n
var result = x <= y
"
,
"
u32 <= u64 less equal
"
);
(
"
var x: u8 = 50
\n
var y: u16 = 30
\n
var result = x >= y
"
,
"
u8 >= u16 greater equal
"
);
(*
Signed comparisons
*)
(
"
var x: i8 = -10
\n
var y: i64 = 100
\n
var result = x < y
"
,
"
i8 < i64 less than
"
);
(
"
var x: i16 = -5
\n
var y: i32 = -10
\n
var result = x > y
"
,
"
i16 > i32 greater than
"
);
]
in
List.
iter (
fun
(
stmt
,
desc
) ->
let
program_text
=
Printf.
sprintf {
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
%
s
return
2
//
XDP_PASS
}
|
} stmt
in
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
int
(
"
comparison promotion func count:
"
^
desc)
1
(
List.
length typed_attributed_functions);
let
(_, tf)
=
List.
hd typed_attributed_functions
in
check
string
(
"
comparison promotion func name:
"
^
desc)
"
test
"
tf.tfunc_name
) comparison_tests
(*
* Test map operations with type promotion
*)
let
test_map_operations_promotion
()
=
let
map_tests
=
[
(*
Map key promotion
*)
({
|
type
IpAddress
=
u32
var
counters
:
hash
<
IpAddress
,
u64
>
(
1000
)
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
ip
:
u16
=
12345
//
u16
should
promote
to
u32
(
IpAddress
)
counters
[ip]
=
100
return
2
//
XDP_PASS
}
|
},
"
map key promotion
"
);
(*
Map value promotion
*)
({
|
type
Counter
=
u64
var
stats
:
hash
<
u32,
Counter
>
(
1000
)
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
value
:
u16
=
1500
//
u16
should
promote
to
u64
(
Counter
)
stats
[
1
]
=
value
return
2
//
XDP_PASS
}
|
},
"
map value promotion
"
);
(*
Map access with arithmetic
*)
({
|
type
PacketSize
=
u16
type
Counter
=
u64
var
stats
:
hash
<
u32,
Counter
>
(
1000
)
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
size
:
PacketSize
=
1500
var
current
=
stats
[
1
]
//
u64
var
new_value
=
current
+
size
//
u64
+
u16
->
u64
stats
[
1
]
=
new_value
return
2
//
XDP_PASS
}
|
},
"
map access with arithmetic promotion
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
bool
(
"
map promotion has typed funcs:
"
^
desc)
true
(
List.
length typed_attributed_functions
>
=
1
);
let
(_, tf)
=
List.
hd typed_attributed_functions
in
check
string
(
"
map promotion func name:
"
^
desc)
"
test
"
tf.tfunc_name
) map_tests
(*
* Test edge cases for type promotion
*)
let
test_type_promotion_edge_cases
()
=
let
edge_case_tests
=
[
(*
Nested arithmetic with multiple promotions
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
a
:
u8
=
10
var
b
:
u16
=
100
var
c
:
u32
=
1000
var
d
:
u64
=
10000
var
result
=
a
+
b
+
c
+
d
//
Chain
of
promotions
return
2
//
XDP_PASS
}
|
},
"
nested arithmetic with multiple promotions
"
);
(*
Function parameters with promotion
*)
({
|
@
helper
fn process(value:
u64
) -> u64 {
return value
*
2
}
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
small
:
u16
=
100
var
result
=
process
(
small
)
//
u16
->
u64
promotion
in
function
call
return
2
//
XDP_PASS
}
|
},
"
function parameter promotion
"
);
(*
Complex expression with promotions
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
a
:
u8
=
5
var
b
:
u16
=
10
var
c
:
u32
=
20
var
d
:
u64
=
40
var
result
=
(
a
+
b
)
*
(
c
+
d
)
//
Mixed
promotions
in
complex
expression
return
2
//
XDP_PASS
}
|
},
"
complex expression with promotions
"
);
(*
Assignment with promotion
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
big
:
u64
=
1000
var
small
:
u16
=
100
big
=
big
+
small
//
u64
=
u64
+
u16
return
2
//
XDP_PASS
}
|
},
"
assignment with promotion
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
bool
(
"
edge case promotion has typed funcs:
"
^
desc)
true
(
List.
length typed_attributed_functions
>
=
1
);
let
test_func
=
List.
find (
fun
(
_
,
tf
) -> tf.tfunc_name
=
"
test
"
) typed_attributed_functions
in
let
(_, tf)
=
test_func
in
check
string
(
"
edge case promotion func name:
"
^
desc)
"
test
"
tf.tfunc_name
) edge_case_tests
(*
* Test null literal typing
*)
let
test_null_literal_typing
()
=
let
null_tests
=
[
(*
Basic null literal
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var x
=
null
return
2
//
XDP_PASS
}
|
},
"
basic null literal
"
);
(*
Null comparison with typed variable
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var
x
:
u32
=
42
if
(
x
==
null
) {
return
1
//
XDP_DROP
}
return
2
//
XDP_PASS
}
|
},
"
null comparison with u32
"
);
(*
Null assignment in variable declaration
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var ptr
=
null
return
2
//
XDP_PASS
}
|
},
"
null assignment in declaration
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
let
ast
=
parse_string program_text
in
let
symbol_table
=
create_symbol_table_with_builtins ast
in
let
(annotated_ast, _typed_programs)
=
type_check_and_annotate_ast_with_builtins ast
in
let
ir_program
=
Kernelscript.Ir_generator.
generate_ir annotated_ast symbol_table
"
test
"
in
check
bool
(
"
null literal typing IR generated:
"
^
desc)
true
(
List.
length ir_program.
Kernelscript.Ir.
source_declarations
>
0
)
) null_tests
(*
* Test null comparisons with different types
*)
let
test_null_comparisons
()
=
let
comparison_tests
=
[
(*
Comparisons with different numeric types
*)
(
"
var x: u8 = 10
\n
var result = x == null
"
,
"
u8 == null
"
);
(
"
var x: u16 = 100
\n
var result = x != null
"
,
"
u16 != null
"
);
(
"
var x: u32 = 1000
\n
var result = x == null
"
,
"
u32 == null
"
);
(
"
var x: u64 = 10000
\n
var result = x != null
"
,
"
u64 != null
"
);
(
"
var x: i8 = -5
\n
var result = x == null
"
,
"
i8 == null
"
);
(
"
var x: i16 = -100
\n
var result = x != null
"
,
"
i16 != null
"
);
(
"
var x: i32 = -1000
\n
var result = x == null
"
,
"
i32 == null
"
);
(
"
var x: i64 = -10000
\n
var result = x != null
"
,
"
i64 != null
"
);
(*
Basic null comparisons
*)
(
"
var ptr = null
\n
var result = ptr == null
"
,
"
null variable == null
"
);
(
"
var ptr = null
\n
var result = ptr != null
"
,
"
null variable != null
"
);
(*
Double null comparison
*)
(
"
var result = null == null
"
,
"
null == null
"
);
(
"
var result = null != null
"
,
"
null != null
"
);
]
in
List.
iter (
fun
(
stmt
,
desc
) ->
let
program_text
=
Printf.
sprintf {
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
%
s
return
2
//
XDP_PASS
}
|
} stmt
in
let
ast
=
parse_string program_text
in
let
symbol_table
=
create_symbol_table_with_builtins ast
in
let
(annotated_ast, _typed_programs)
=
type_check_and_annotate_ast_with_builtins ast
in
let
ir_program
=
Kernelscript.Ir_generator.
generate_ir annotated_ast symbol_table
"
test
"
in
check
bool
(
"
null comparison IR generated:
"
^
desc)
true
(
List.
length ir_program.
Kernelscript.Ir.
source_declarations
>
0
)
) comparison_tests
(*
* Test map operations with null semantics
*)
let
test_map_null_semantics
()
=
let
map_null_tests
=
[
(*
Map access returning nullable value
*)
({
|
var
test_map
:
hash
<
u32,
u64
>
(
100
)
@
xdp
fn
test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var value
=
test_map[
42
]
if
(value
==
null) {
return
1
//
XDP_DROP
}
return
2
//
XDP_PASS
}
|},
"
map access null check
"
);
(*
Null initialization pattern
*)
({
|
var
counters
:
hash
<
u32,
u32
>
(
100
)
@
xdp
fn
test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var count
=
counters[
1
]
if
(count
==
null) {
counters[
1
]
=
1
}
else
{
counters[
1
]
=
count
+
1
}
return
2
//
XDP_PASS
}
|},
"
null initialization pattern
"
);
(*
Multiple map null checks
*)
({
|
var
flows
:
hash
<
u32,
u64
>
(
100
)
var
packets
:
hash
<
u32,
u32
>
(
100
)
@
xdp
fn
test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var flow
=
flows[
123
]
var packet_count
=
packets[
123
]
if
(flow
==
null
||
packet_count
==
null) {
return
1
//
XDP_DROP
}
return
2
//
XDP_PASS
}
|},
"
multiple map null checks
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
let
ast
=
parse_string program_text
in
let
symbol_table
=
create_symbol_table_with_builtins ast
in
let
(annotated_ast, _typed_programs)
=
type_check_and_annotate_ast_with_builtins ast
in
let
ir_program
=
Kernelscript.Ir_generator.
generate_ir annotated_ast symbol_table
"
test
"
in
check
bool
(
"
map null semantics IR generated:
"
^
desc)
true
(
List.
length ir_program.
Kernelscript.Ir.
source_declarations
>
0
)
) map_null_tests
(*
* Test null vs throw pattern adherence
*)
let
test_null_vs_throw_pattern
()
=
let
pattern_tests
=
[
(*
Correct: null for expected absence
*)
({
|
var
cache
:
hash
<
u32,
u64
>
(
100
)
@
xdp
fn
test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var cached_value
=
cache[
42
]
if
(cached_value
==
null) {
//
Key
doesn't exist
-
expected case
cache[
42
]
=
100
return
2
//
XDP_PASS
}
return cached_value
}
|},
"
null for expected absence
"
);
(*
Correct: error checking (simplified without throw)
*)
({
|
@
helper
fn validate_input(value:
u32
) -> u32 {
if
(value
>
1000
) {
return
0
//
Error
case
}
return value
*
2
}
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var result
=
validate_input(
500
)
return
2
//
XDP_PASS
}
|
},
"
error validation pattern
"
);
(*
Function returning nullable value
*)
({
|
var
data
:
hash
<
u32,
u32
>
(
100
)
@
helper
fn
lookup_value
(
key
:
u32
) ->
u32
{
var value
=
data[key]
if
(value
==
null) {
return
0
//
Default
value
for
missing key
}
return value
}
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var result
=
lookup_value(
42
)
return
2
//
XDP_PASS
}
|
},
"
function with nullable return pattern
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
bool
(
"
null vs throw pattern has typed funcs:
"
^
desc)
true
(
List.
length typed_attributed_functions
>
=
1
)
) pattern_tests
(*
* Test comprehensive null semantics
*)
let
test_null_semantics
()
=
let
comprehensive_tests
=
[
(*
Null in conditional expressions
*)
({
|
var
test_map
:
hash
<
u32,
u32
>
(
100
)
@
xdp
fn
test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var value
=
test_map[
1
]
var result
=
0
if
(value
==
null) {
result
=
0
}
else
{
result
=
value
}
return
2
//
XDP_PASS
}
|},
"
null in if-else expression
"
);
(*
Null in logical operations
*)
({
|
var
map1
:
hash
<
u32,
u32
>
(
100
)
var
map2
:
hash
<
u32,
u32
>
(
100
)
@
xdp
fn
test
(
ctx
:
*
xdp_md) ->
xdp_action
{
var val1
=
map1[
1
]
var val2
=
map2[
1
]
if
(val1
!=
null
&&
val2
!=
null) {
return
2
//
XDP_PASS
}
return
2
//
XDP_PASS
}
|},
"
null in logical AND
"
);
(*
Basic null assignments
*)
({
|
@
xdp fn test(ctx:
*xdp_md
) -> xdp_action {
var x
=
null
if
(x
==
null) {
return
1
//
XDP_DROP
}
return
2
//
XDP_PASS
}
|
},
"
basic null assignment and check
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
let
ast
=
parse_string program_text
in
let
(_enhanced_ast, typed_attributed_functions)
=
type_check_and_annotate_ast_with_builtins ast
in
check
bool
(
"
comprehensive null has typed funcs:
"
^
desc)
true
(
List.
length typed_attributed_functions
>
=
1
)
) comprehensive_tests
(*
* Helper function to check if string contains substring
*)
let
contains_substr
str
substr
=
try
let
_
=
Str.
search_forward (
Str.
regexp_string substr) str
0
in
true
with
Not_found
->
false
(*
* Test XDP signature validation enforcement
*)
let
test_xdp_signature_validation
()
=
let
invalid_signature_tests
=
[
(*
Missing context parameter
*)
({
|
@
xdp fn test
()
-> xdp_action {
return
2
//
XDP_PASS
}
|
},
"
missing context parameter
"
);
(*
Wrong parameter type
*)
({
|
@
xdp fn test(wrong_param:
u32
) -> xdp_action {
return
2
//
XDP_PASS
}
|
},
"
wrong parameter type
"
);
(*
No parameters and wrong return type
*)
({
|
@
xdp fn test
()
-> u32 {
return
0
}
|
},
"
no parameters and wrong return type
"
);
]
in
List.
iter (
fun
(
program_text
,
desc
) ->
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL