mirror of https://github.com/deadw00d/AROS.git
Add unit test for SameLock
This commit is contained in:
parent
8319357595
commit
5325d087fb
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
Copyright © 2024, The AROS Development Team. All rights reserved.
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <proto/exec.h>
|
||||
#include <proto/dos.h>
|
||||
#include <dos/dos.h>
|
||||
|
||||
#include "../test-util.h"
|
||||
|
||||
#if defined(__AROS__)
|
||||
#include <CUnit/CUnitCI.h>
|
||||
#endif
|
||||
|
||||
CU_SUITE_SETUP()
|
||||
{
|
||||
return CUE_SUCCESS;
|
||||
}
|
||||
|
||||
CU_SUITE_TEARDOWN()
|
||||
{
|
||||
return CUE_SUCCESS;
|
||||
}
|
||||
|
||||
CU_TEST_SETUP()
|
||||
{
|
||||
}
|
||||
|
||||
CU_TEST_TEARDOWN()
|
||||
{
|
||||
}
|
||||
|
||||
void test_samelock_same_different(void)
|
||||
{
|
||||
BPTR lock1 = Lock("SYS:Libs/asl.library", SHARED_LOCK);
|
||||
BPTR lock2 = Lock("SYS:Libs/asl.library", SHARED_LOCK);
|
||||
BPTR lock3 = Lock("RAM:ENV/Language", SHARED_LOCK);
|
||||
BPTR lock4 = BNULL;
|
||||
LONG res;
|
||||
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(lock1, BNULL);
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(lock2, BNULL);
|
||||
|
||||
res = SameLock(lock1, lock2);
|
||||
CU_ASSERT_EQUAL(res, LOCK_SAME);
|
||||
|
||||
res = SameLock(lock1, BNULL);
|
||||
CU_ASSERT_EQUAL(res, LOCK_DIFFERENT);
|
||||
|
||||
res = SameLock(lock1, lock3);
|
||||
CU_ASSERT_EQUAL(res, LOCK_DIFFERENT);
|
||||
|
||||
lock4 = DupLock(lock1);
|
||||
res = SameLock(lock2, lock4);
|
||||
CU_ASSERT_EQUAL(res, LOCK_SAME);
|
||||
|
||||
UnLock(lock1);
|
||||
UnLock(lock2);
|
||||
UnLock(lock3);
|
||||
UnLock(lock4);
|
||||
}
|
||||
|
||||
void test_samelock_same_volume(void)
|
||||
{
|
||||
BPTR lock1 = Lock("SYS:Libs/asl.library", SHARED_LOCK);
|
||||
BPTR lock2 = Lock("SYS:Libs/locale.library", SHARED_LOCK);
|
||||
LONG res;
|
||||
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(lock1, BNULL);
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(lock2, BNULL);
|
||||
|
||||
res = SameLock(lock1, lock2);
|
||||
CU_ASSERT_EQUAL(res, LOCK_SAME_VOLUME);
|
||||
|
||||
UnLock(lock1);
|
||||
UnLock(lock2);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CU_CI_DEFINE_SUITE("SameLock_Suite", __cu_suite_setup, __cu_suite_teardown, __cu_test_setup, __cu_test_teardown);
|
||||
CUNIT_CI_TEST(test_samelock_same_different);
|
||||
CUNIT_CI_TEST(test_samelock_same_volume);
|
||||
return CU_CI_RUN_SUITES();
|
||||
}
|
|
@ -59,6 +59,7 @@ CUNITDOSTESTFILES := \
|
|||
cunit-dos-createnewproc \
|
||||
cunit-dos-fileseek \
|
||||
cunit-dos-readargs \
|
||||
cunit-dos-samelock \
|
||||
cunit-dos-systemtags \
|
||||
cunit-dos-systemtags-stack-slave
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ static inline void Click(struct Window *w, LONG x, LONG y)
|
|||
#define STDARGS __stdargs
|
||||
#define INTERRUPT __interrupt
|
||||
#define IPTR ULONG
|
||||
#define BNULL (0)
|
||||
|
||||
#define BOOPSI_DISPATCHER(type, func, cl, obj, msg) \
|
||||
static ULONG SAVEDS func(REG(a0, struct IClass *cl), \
|
||||
|
|
|
@ -33,6 +33,7 @@ If NOT WARN
|
|||
Execute S/Test cunit/dos/cunit-dos-createnewproc ;CreateNewProc_Suite
|
||||
Execute S/Test cunit/dos/cunit-dos-fileseek ;FileSeek_Suite
|
||||
Execute S/Test cunit/dos/cunit-dos-readargs ;ReadArgs_Suite
|
||||
Execute S/Test cunit/dos/cunit-dos-samelock ;SameLock_Suite
|
||||
Execute S/Test cunit/dos/cunit-dos-smallcodemodel ;SmallCodeModel_Suite
|
||||
Execute S/Test cunit/dos/cunit-dos-systemtags ;SystemTags_Suite
|
||||
|
||||
|
|
Loading…
Reference in New Issue