def test_getuai(self): """ test getuai """ # setuai requires BYPASS or SYSPRV il = ILE3.new() ILE3.addstr(il, JPI.JPI__ACCOUNT, None, 8) ILE3.addstr(il, JPI.JPI__USERNAME, None, 12) status, pid = SYS.getjpi(0, None, il) jpi_account = ILE3.getstr(il, 0, 0) jpi_username = ILE3.getstr(il, 1, 0) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) self.assertNotEqual(jpi_account, '') self.assertNotEqual(jpi_username, '') self.assertNotEqual(pid, 0) il = ILE3.new() ILE3.addstr(il, UAI.UAI__ACCOUNT, None, 32) ILE3.addstr(il, UAI.UAI__DEFDIR, None, 64) ILE3.addint(il, UAI.UAI__UIC, DSC.DSC_K_DTYPE_LU, 0) status = SYS.getuai(jpi_username, il) uai_account = ILE3.getstr(il, 0, 0) uai_defdir = ILE3.getstr(il, 1, 1) uai_uic = ILE3.getint(il, 2) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) self.assertEqual(jpi_account.strip(), uai_account.strip()) self.assertNotEqual(uai_defdir, '') self.assertNotEqual(uai_uic, 0)
def test_logical_name(self): """ test create, translate and delete logical name """ log_name = 'PythonTestCRELNM' log_value = 'Value of PythonTestCRELNM' log_table = 'LNM$PROCESS_TABLE' il = ILE3.new() ILE3.addstrn(il, LNM.LNM__STRING, log_value, len(log_value)) status = SYS.crelnm(0, log_table, log_name, PSL.PSL_C_USER, il) ILE3.delete(il) self.assertIn(status, (SS.SS__NORMAL, SS.SS__SUPERSEDE)) il = ILE3.new() ILE3.addint(il, LNM.LNM__INDEX, DSC.DSC_K_DTYPE_LU, 0) ILE3.addint(il, LNM.LNM__ATTRIBUTES, DSC.DSC_K_DTYPE_LU, 0) ILE3.addint(il, LNM.LNM__LENGTH, DSC.DSC_K_DTYPE_LU, 0) ILE3.addstr(il, LNM.LNM__STRING, None, 255) ILE3.addstr(il, LNM.LNM__TABLE, None, 32) status = SYS.trnlnm(LNM.LNM_M_CASE_BLIND, None, log_name, PSL.PSL_C_USER, il) attributes = ILE3.getint(il, 1) value_length = ILE3.getint(il, 2) value_str = ILE3.getstr(il, 3, 0) table_str = ILE3.getstr(il, 4, 0) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) self.assertTrue(attributes & LNM.LNM_M_EXISTS) self.assertEqual(value_length, len(log_value)) self.assertEqual(value_str, log_value) self.assertEqual(table_str, log_table) status = SYS.dellnm(log_table, log_name, PSL.PSL_C_USER) self.assertEqual(status, SS.SS__NORMAL)
def test_getrmi(self): """ test getrmi """ il = ILE3.new() ILE3.addint(il, RMI.RMI__CPUIDLE, DSC.DSC_K_DTYPE_QU, 0) status = SYS.getrmi(il) cpu_idle = ILE3.getint(il, 0) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) self.assertGreater(cpu_idle, 0)
def test_addbin_getbyte(self): """ tests add binary data and get byte """ self.il = ILE3.new() self.assertEqual(0, ILE3.size(self.il)) ILE3.addbin(self.il, SYI.SYI__ARCH_TYPE, 0x0102030405060708, 2, 5) self.assertEqual(1, ILE3.size(self.il)) self.assertEqual(0x04, ILE3.getbyte(self.il, 0, 2)) ILE3.delete(self.il) self.il = None
def test_getjpi(self): """ test getjpi """ il = ILE3.new() ILE3.addint(il, JPI.JPI__PPGCNT, DSC.DSC_K_DTYPE_LU, 0) status, pid = SYS.getjpi(0, None, il) ppgcnt = ILE3.getint(il, 0) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) self.assertGreater(pid, 0) self.assertGreater(ppgcnt, 0)
def test_addstrn(self): """ tests add strn """ self.il = ILE3.new() self.assertEqual(0, ILE3.size(self.il)) ILE3.addstrn(self.il, SYI.SYI__HW_NAME, '1234567890', 5) self.assertEqual(1, ILE3.size(self.il)) hw_name = ILE3.getstr(self.il, 0, 0) self.assertEqual(hw_name, '12345') ILE3.delete(self.il) self.il = None
def test_addint_getint(self): """ tests add int and get int """ self.il = ILE3.new() self.assertEqual(0, ILE3.size(self.il)) ILE3.addint(self.il, SYI.SYI__ARCH_TYPE, DSC.DSC_K_DTYPE_QU, 0x0102030405060708) self.assertEqual(1, ILE3.size(self.il)) self.assertEqual(0x0102030405060708, ILE3.getint(self.il, 0)) ILE3.delete(self.il) self.il = None
def test_addstrd(self): """ tests add strd """ self.il = ILE3.new() self.assertEqual(0, ILE3.size(self.il)) ILE3.addstrd(self.il, SYI.SYI__HW_NAME, '1234567890', 5) # one byte reserved for length self.assertEqual(1, ILE3.size(self.il)) hw_name = ILE3.getstr(self.il, 0, 1) self.assertEqual(hw_name, '1234') ILE3.delete(self.il) self.il = None
def test_getsyi(self): """ test getsyi """ il = ILE3.new() ILE3.addstr(il, SYI.SYI__ARCH_NAME, None, 16) ILE3.addint(il, SYI.SYI__ARCH_TYPE, DSC.DSC_K_DTYPE_LU, 0) csid = -1 status, csid = SYS.getsyi(csid, None, il) arch_name = ILE3.getstr(il, 0, 0) arch_type = ILE3.getint(il, 1) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) self.assertNotEqual(arch_name, '') self.assertIn(arch_type, (1, 2, 3))
def test_device_scan(self): """ test device_scan """ il = ILE3.new() ILE3.addint(il, DVS.DVS__DEVCLASS, DSC.DSC_K_DTYPE_LU, DC.DC__DISK) devices = [] status, dev_name, context = SYS.device_scan('*', il, 0) while status == SS.SS__NORMAL: devices.append(dev_name) status, dev_name, context = SYS.device_scan('*', il, context) ILE3.delete(il) self.assertGreater(len(devices), 0) self.assertEqual(status, SS.SS__NOMOREDEV)
def test_getstr(self): """ tests getting str """ self.il = ILE3.new() self.assertEqual(0, ILE3.size(self.il)) ILE3.addstr(self.il, SYI.SYI__HW_NAME, None, 64) self.assertEqual(1, ILE3.size(self.il)) status, _ = SYS.getsyi(0, None, self.il) self.assertEqual(1, status) self.assertEqual(1, ILE3.size(self.il)) hw_name = ILE3.getstr(self.il, 0, 0) self.assertEqual(1, ILE3.size(self.il)) ILE3.delete(self.il) self.il = None self.assertNotIn(hw_name, (None, ''))
def test_getqui(self): """ test getqui """ il = ILE3.new() ILE3.addstr(il, QUI.QUI__SEARCH_NAME, '*', 32) ILE3.addstr(il, QUI.QUI__QUEUE_NAME, None, 32) context = -1 status, context = SYS.getqui(QUI.QUI__DISPLAY_QUEUE, context, il) qui_name = ILE3.getstr(il, 1, 0) ILE3.delete(il) self.assertIn(status, (JBC.JBC__NOMOREQUE, SS.SS__NORMAL)) self.assertNotEqual(qui_name, '') if status == SS.SS__NORMAL: status, context = SYS.getqui(QUI.QUI__CANCEL_OPERATION, context, None) self.assertEqual(status, SS.SS__NORMAL)
def test_getlki(self): """ test getlki """ locks = 0 lkiaddr = 0 il = ILE3.new() ILE3.addint(il, LKI.LKI__LOCKID, DSC.DSC_K_DTYPE_LU, 0) while True: status, lkiaddr = SYS.getlki(lkiaddr, il) if status != SS.SS__NORMAL: break lockid = ILE3.getint(il, 0) self.assertEqual(lockid & 0xffff, lkiaddr & 0xffff) locks = locks + 1 ILE3.delete(il) self.assertEqual(status, SS.SS__NOMORELOCK)
def test_getdvi(self): """ test getdvi """ il = ILE3.new() ILE3.addint(il, DVS.DVS__DEVCLASS, DSC.DSC_K_DTYPE_LU, DC.DC__DISK) status, dev_name, _ = SYS.device_scan('*', il, 0) ILE3.delete(il) self.assertIn(status, (SS.SS__NORMAL, SS.SS__NOMOREDEV)) il = ILE3.new() ILE3.addint(il, DVI.DVI__DEVCHAR, DSC.DSC_K_DTYPE_LU, 0) status = SYS.getdvi(dev_name, il) characteristics = ILE3.getint(il, 0) ILE3.delete(il) self.assertEqual(status, SS.SS__NORMAL) DEV_M_DIR = 0x8 # has directories self.assertTrue(characteristics & DEV_M_DIR) DEV_M_FOD = 0x4000 # is file oriented self.assertTrue(characteristics & DEV_M_FOD)