Add tests for umask_get() and umask_set()

This commit is contained in:
2025-07-25 11:13:25 +02:00
parent 511be406be
commit 490f287c09
2 changed files with 47 additions and 1 deletions

View File

@@ -182,7 +182,7 @@ clampu:
;----- umask_set(umask) -----;
; Sets umask
; Return value: Return value of syscall sys_umask
; Return value: Return value of syscall sys_umask (old value of umask)
; Used registers:
; rax* syscall >> (ret)
; rdi umask to set

View File

@@ -108,6 +108,7 @@ section .rodata
TEST_maxu equ 1
TEST_clamp equ 1
TEST_clampu equ 1
TEST_umask equ 1
;console.asm
TEST_print equ 1
TEST_puts equ 1
@@ -218,6 +219,14 @@ section .rodata
addTest(clampu2, "clampu(0, 1, 1000)")
addTest(clampu3, "clampu(1337, 1, 1000)")
addTest(clampu4, "clampu(MAX_UINT64, 0, MAX_UINT32)")
;umask_set() / umask_get()
addTestHeader(_umask, "umask_[g|s]et")
addTest(umask1, "umask_get()")
addTest(umask2, "umask_set(0027q)")
addTest(umask3, "umask_get()")
addTest(umask4, "umask_set(0022q)")
addTest(umask5, "umask_get()")
addTest(umask6, "umask_get()") ;extra test to check if it wasn't changed
;print()
addTestHeader(_print, "print")
addTest(print1, "print(''Hello, world!\n'')")
@@ -687,6 +696,43 @@ _start:
assert_u_eq(MAX_UINT32)
%endif
;--- umask_set() / umask_get()
%if TEST_umask
printTestHeader(_umask)
; TEST 1
printTest(umask1)
call umask_get
assert_u_eq(0022q) ;Bad test, since umask could be different.
; TEST 2
printTest(umask2)
mov rdi, 0027q
call umask_set
assert_u_eq(0022q)
; TEST 3
printTest(umask3)
call umask_get
assert_u_eq(0027q)
; TEST 4
printTest(umask4)
mov rdi, 0022q
call umask_set
assert_u_eq(0027q)
; TEST 5
printTest(umask5)
call umask_get
assert_u_eq(0022q)
; TEST 6
printTest(umask6)
call umask_get
assert_u_eq(0022q)
%endif
;--- print()
%if TEST_print
printTestHeader(_print)