interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / host / tests / vfiocheck.om

137 lines · 3790 bytes Raw Blame History
1note Native compiler refusal driver for VFIO words. argv[1] names the exact compiler under test.
2text infile "case.om"
3text outfile "case.elf"
4text errfile "case.err"
5text passed "PASS 16 VFIO compiler refusals\n"
6text a "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15209 a 0 0\nret 0\nend\n"
7text b "global a uchar 32\nfn main to int\nq = uint 15207\nr = vfioctl neg int 1 q a 0 8\nret 0\nend\n"
8text c "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15216 a 0 32\nret 0\nend\n"
9text d "text a \"readonly\"\nfn main to int\nr = vfioctl neg int 1 uint 15207 a 0 8\nret 0\nend\n"
10text e "global a uint 32\nfn main to int\nr = vfioctl neg int 1 uint 15212 a 0 32\nret 0\nend\n"
11text f "global a uchar 32\nfn main to int\nr = vfioctl long 1 uint 15207 a 0 8\nret 0\nend\n"
12text g "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 ulong 15207 a 0 8\nret 0\nend\n"
13text h "fn test a edit uchar 32 to long\nret vfioctl neg int 1 uint 15207 a 0 8\nend\n"
14text j "global a uint 32\nfn main to int\nr = vfiomap neg int 1 a 0 32\nret 0\nend\n"
15text k "fn test a edit uchar 32 to long\nret vfiomap neg int 1 a 0 32\nend\n"
16text m "global a uchar 32\nfn main to int\nr = vfiomap long 1 a 0 32\nret 0\nend\n"
17text n "global a uint 32\nfn main to int\nr = vfioctl neg int 1 uint 15210 a 0 8\nret 0\nend\n"
18text o "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15215 a 0 0\nret 0\nend\n"
19text p "global a uint 32\nfn main to int\nr = vfiomapw neg int 1 a 0 32\nret 0\nend\n"
20text s "fn test a edit uchar 32 to long\nret vfiomapw neg int 1 a 0 32\nend\n"
21text t "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15219 a 0 32\nret 0\nend\n"
22global packet uchar 4096
23global status uchar 4
24global tmp uchar 1
25fn expect yes bool to void
26if not yes
27exit int 80
28end
29end
30fn source num int fd int to int
31r = long 0
32want = int 9
33if eq num 0
34r = write fd a 0 len a
35end
36if eq num 1
37r = write fd b 0 len b
38end
39if eq num 2
40r = write fd c 0 len c
41end
42if eq num 3
43r = write fd d 0 len d
44want = 20
45end
46if eq num 4
47r = write fd e 0 len e
48want = 7
49end
50if eq num 5
51r = write fd f 0 len f
52want = 7
53end
54if eq num 6
55r = write fd g 0 len g
56want = 7
57end
58if eq num 7
59r = write fd h 0 len h
60end
61if eq num 8
62r = write fd j 0 len j
63want = 7
64end
65if eq num 9
66r = write fd k 0 len k
67end
68if eq num 10
69r = write fd m 0 len m
70want = 7
71end
72if eq num 11
73r = write fd n 0 len n
74want = 7
75end
76if eq num 12
77r = write fd o 0 len o
78end
79if eq num 13
80r = write fd p 0 len p
81want = 7
82end
83if eq num 14
84r = write fd s 0 len s
85end
86if eq num 15
87r = write fd t 0 len t
88end
89expect gt r 0
90ret want
91end
92fn main to int
93expect eq argcnt 2
94size = argread 1 packet 4 4092
95expect and gt size 0 le size 4092
96put packet 0 1
97put packet 2 uchar and size 255
98put packet 3 uchar shr size 8
99for num int 16
100input = fopen infile 0 len infile 524482 384
101output = fopen outfile 0 len outfile 524482 384
102errors = fopen errfile 0 len errfile 524482 384
103expect ge input 0
104expect ge output 0
105expect ge errors 0
106want = source num int input
107expect eq fseek int input 0 0 0
108pid = fork
109expect ge pid 0
110if eq pid 0
111expect eq dupfd int input 0 0 0
112expect eq dupfd int output 1 0 1
113expect eq dupfd int errors 2 0 2
114r = execprog packet 0 add ulong size 4
115exit int 81
116end
117expect eq waitpid int pid status 0 4 0 pid
118if ne get status 0 0
119ret add num 1
120end
121if ne get status 1 uchar want
122ret add num 1
123end
124expect eq fseek int output 0 0 0
125expect eq read int output tmp 0 1 0
126expect eq fseek int errors 0 0 0
127expect eq read int errors tmp 0 1 1
128expect eq fclose int input 0
129expect eq fclose int output 0
130expect eq fclose int errors 0
131expect eq unlink infile 0 len infile 0
132expect eq unlink outfile 0 len outfile 0
133expect eq unlink errfile 0 len errfile 0
134end
135expect eq write 1 passed 0 len passed long len passed
136ret 0
137end