Import
This commit is contained in:
23
Test/HyperionOS-units/bin/hunit
Normal file
23
Test/HyperionOS-units/bin/hunit
Normal file
@@ -0,0 +1,23 @@
|
||||
local fs=require("sys.fs")
|
||||
local units=fs.list("/usr/lib/hunit/")
|
||||
fs.mkdir("/tmp/hunit/")
|
||||
local errors={}
|
||||
for i,v in ipairs(units) do
|
||||
print("running unit "..v)
|
||||
local code=fs.readAllText("/usr/lib/hunit/"..v)
|
||||
local func, err=load(code, "@"..v)
|
||||
if not func then
|
||||
print(" [ERROR]:"..err)
|
||||
end
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
local ok, err=pcall(func)
|
||||
if not ok then
|
||||
print(" [ERROR]:"..err)
|
||||
table.insert(errors, v)
|
||||
else
|
||||
print(" [SUCCESS]")
|
||||
end
|
||||
end
|
||||
|
||||
print(tostring(#errors).." units failed")
|
||||
return 0
|
||||
3
Test/HyperionOS-units/usr/lib/hunit/dir.unit
Normal file
3
Test/HyperionOS-units/usr/lib/hunit/dir.unit
Normal file
@@ -0,0 +1,3 @@
|
||||
local fs = require("sys.fs")
|
||||
assert(fs.mkdir("/tmp/hunit/testdir"), "failed to make directory")
|
||||
assert(fs.isDir("/tmp/hunit/testdir"), "directory does not exist")
|
||||
10
Test/HyperionOS-units/usr/lib/hunit/file.unit
Normal file
10
Test/HyperionOS-units/usr/lib/hunit/file.unit
Normal file
@@ -0,0 +1,10 @@
|
||||
local fd = syscall.VFS_open("/tmp/hunit/testfile.txt", "w")
|
||||
syscall.VFS_write(fd, "This is a test file")
|
||||
syscall.VFS_close(fd)
|
||||
local fd = syscall.VFS_open("/tmp/hunit/testfile.txt", "r")
|
||||
local text = syscall.VFS_read(fd, 64)
|
||||
syscall.VFS_close(fd)
|
||||
|
||||
if text~="This is a test file" then
|
||||
error("File failed to write/read")
|
||||
end
|
||||
Reference in New Issue
Block a user