0690 nwnss: harden scheduler userspace compat coverage
This commit is contained in:
@@ -1,13 +1,28 @@
|
||||
#include <include/nssOSAPIs.h>
|
||||
#include <include/schedule.h>
|
||||
#include <include/pssmpk.h>
|
||||
#include <include/xError.h>
|
||||
|
||||
#define CHECK(expr) do { if (!(expr)) return __LINE__; } while (0)
|
||||
|
||||
extern LONG Delayed;
|
||||
|
||||
static int scheduled_called;
|
||||
static int scheduled_saw_lock;
|
||||
static void *scheduled_arg;
|
||||
|
||||
static void scheduled_callback(void *arg)
|
||||
{
|
||||
scheduled_called++;
|
||||
scheduled_arg = arg;
|
||||
scheduled_saw_lock = MPKNSS_I_OWN_SPINLOCK();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
LONG before;
|
||||
zWorkProc_s work;
|
||||
THREAD self;
|
||||
|
||||
MPKNSS_INIT_LOCK();
|
||||
|
||||
@@ -25,5 +40,55 @@ int main(void)
|
||||
CHECK(MPKNSS_I_OWN_SPINLOCK());
|
||||
MPKNSS_UNLOCK();
|
||||
|
||||
self = kCurrentThread();
|
||||
CHECK(self != (THREAD)0);
|
||||
CHECK((THREAD)ThreadId() == self);
|
||||
|
||||
ZOS_YieldThread();
|
||||
Yield();
|
||||
ZOS_Sleep();
|
||||
Wait();
|
||||
ZOS_WakeUp(self);
|
||||
Continue(self);
|
||||
|
||||
CHECK(ZOS_ScheduleWorkToDo(NULL) == zERR_BAD_PARAMETER_VALUE);
|
||||
CHECK(ZOS_CancelWorkToDo(NULL) == zOK);
|
||||
|
||||
work.zwork.osReserved = 0;
|
||||
work.zwork.ProcedureToCall = (voidfunc_t)scheduled_callback;
|
||||
work.zwork.WorkResourceTag = NULL;
|
||||
work.zwork.reserved[0] = 0;
|
||||
work.zwork.reserved[1] = 0;
|
||||
work.info = NULL;
|
||||
|
||||
scheduled_called = 0;
|
||||
scheduled_saw_lock = -1;
|
||||
scheduled_arg = NULL;
|
||||
CHECK(ScheduleWork(&work) == zOK);
|
||||
CHECK(scheduled_called == 1);
|
||||
CHECK(scheduled_arg == &work);
|
||||
CHECK(scheduled_saw_lock == 0);
|
||||
|
||||
scheduled_called = 0;
|
||||
scheduled_saw_lock = -1;
|
||||
scheduled_arg = NULL;
|
||||
CHECK(ScheduleFastWork(&work) == zOK);
|
||||
CHECK(scheduled_called == 1);
|
||||
CHECK(scheduled_arg == &work);
|
||||
CHECK(scheduled_saw_lock == 0);
|
||||
|
||||
scheduled_called = 0;
|
||||
scheduled_saw_lock = -1;
|
||||
scheduled_arg = NULL;
|
||||
CHECK(MPKNSS_LOCK());
|
||||
CHECK(ScheduleWork(&work) == zOK);
|
||||
CHECK(MPKNSS_I_OWN_SPINLOCK());
|
||||
CHECK(MPKNSS_UNLOCK());
|
||||
CHECK(scheduled_called == 1);
|
||||
CHECK(scheduled_arg == &work);
|
||||
CHECK(scheduled_saw_lock == 0);
|
||||
|
||||
CHECK(CancelWork(&work) == zOK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user