/************************************************************************************/ /* Software Distribution - Object CUR */ /* FILENAME : QualifyTest.rex */ /* TYPE : ObjectRexx - OS/2, Win32, Linux, AIX */ /* DESCRIPTION : Tests the LDSFileSystem FullyQualifyFINDfilename method */ /* */ /* AUTHOR : Michael D Lueck */ /* mlueck@lueckdatasystems.com */ /* */ /* NEEDS : LDSSystemInfo.cls */ /* LDSLogging.cls */ /* LDSParmCheck.cls */ /* LDSRexxUtil.cls */ /* LDSFileSystem.cls */ /* */ /* USEAGE : */ /* */ /* REVISION HISTORY */ /* */ /* DATE REVISED BY DESCRIPTION OF CHANGE */ /* ---------- ---------- ------------------------------------------------------- */ /* 08/26/2004 MDL Initial Creation */ /************************************************************************************/ /* Create a LDSSystemInfo object, which requires that the result of a parse source is passed to it */ /* Every program based on ObjCUR must make these calls - forth cominging objects will require a handle to this object */ parse source TheSource LDSSystemInfo=.LDSSystemInfo~new(TheSource) if LDSSystemInfo~Test\='LDSSystemInfo' then do rc=LineOut('STDERR', 'Main -> Bad LDSSystemInfo Instance, Exiting Program!') exit 1 end /* Create a LDSLogging object, which requires that the global LDSSystemInfo object be passed to it so it may keep a handle to that object */ /* Ever program based on ObjCUR must make this call - forth cominging objects will require a handle to this object */ LDSLogging=.LDSLogging~new(LDSSystemInfo) if LDSLogging~Test\='LDSLogging' then do rc=LineOut('STDERR', 'Main -> Bad LDSLogging Instance, Exiting Program!') exit 1 end /* Handle the command line params */ parse arg Args ParmCheck=.ParmCheck~new(LDSSystemInfo, LDSLogging) if ParmCheck~Test\='ParmCheck' then do rc=LineOut('STDERR', 'Main -> Bad ParmCheck Instance, Exiting Program!') exit 1 end if \ ParmCheck~ParmCheck(Args) then do exit 1 end /* Build an instance of LDSRexxUtil */ LDSRexxUtil=.LDSRexxUtil~new(LDSSystemInfo, LDSLogging) if LDSRexxUtil~Test\='LDSRexxUtil' then do LDSLogging~Error('Main -> Bad LDSRexxUtil Instance, Exiting Program!') LDSLogging~Logger('Main -> Bad LDSRexxUtil Instance, Exiting Program!') exit 1 end /* Create a LDSFileSystem object */ LDSFileSystem=.LDSFileSystem~new(LDSSystemInfo, LDSLogging) if LDSFileSystem~Test\='LDSFileSystem' then do rc=LineOut('STDERR', 'Main -> Bad LDSFileSystem Instance, Exiting Program!') exit 1 end /* Set the program log filename */ LDSLogging~SETLoggerFilename(LDSRexxUtil~LDSFileSpec('DRIVE', LDSSystemInfo~RXSourceFullPathFilename) || LDSRexxUtil~LDSFileSpec('PATH', LDSSystemInfo~RXSourceFullPathFilename) || date('S') || '.' || left(LDSRexxUtil~LDSFileSpec('NAME', LDSSystemInfo~RXSourceFullPathFilename), lastpos('.', LDSRexxUtil~LDSFileSpec('NAME', LDSSystemInfo~RXSourceFullPathFilename))-1) || '.LOG') LDSLogging~Console('Starting QualifyTest...') LDSLogging~Logger('Starting QualifyTest...') ArcChar=LDSFileSystem~GetArcChar() /* Query the Working Directory */ pwd=directory() if pwd~length>3 & pwd~right(1)\=ArcChar then pwd=pwd || ArcChar LDSLogging~Console('pwd=' || pwd) LDSLogging~Logger('pwd=' || pwd) /* Compute one directoy up from the Working Directory */ /* Handle running from the root dir first, should only be on Arc Char in the pwd */ if pwd~countstr(ArcChar)=1 then do pwdup1=pwd end /* if */ else do pwdup1=UpOneDir(pwd, ArcChar) end LDSLogging~Console('pwdup1=' || pwdup1) LDSLogging~Logger('pwdup1=' || pwdup1) /* Run cross-platform tests... */ /* Current Dir */ rc=RunTest('.', pwd) rc=RunTest('*', pwd || '*') rc=RunTest('filename', pwd || 'filename') rc=RunTest('dirname' || ArcChar, pwd || 'dirname' || ArcChar) /* Current Dir + One Level */ rc=RunTest('.' || ArcChar || 'dirname' || ArcChar || '*', pwd || 'dirname' || ArcChar || '*') rc=RunTest('.' || ArcChar || 'filename', pwd || 'filename') rc=RunTest('.' || ArcChar || 'dirname' || ArcChar, pwd || 'dirname' || ArcChar) /* Up one from Current Dir */ rc=RunTest('..', pwdup1) rc=RunTest('..' || ArcChar || '*', pwdup1 || '*') rc=RunTest('..' || ArcChar || 'filename', pwdup1 || 'filename') rc=RunTest('..' || ArcChar || 'dirname' || ArcChar, pwdup1 || 'dirname' || ArcChar) /* Base tests on host OS Arc Char */ select /* \ */ when ArcChar='\' then do /* Get some Env Vars so we know about this workstation */ SystemRoot=value('SystemRoot',,'ENVIRONMENT') || ArcChar /* Root (Of current drive in DOS land) */ rc=RunTest(ArcChar, LDSRexxUtil~LDSFileSpec('DRIVE', pwd) || ArcChar) /* Current directory of a specified drive */ /* For this test we expect NOT to be running on the same drive as Windows is installed on... */ trash=directory(SystemRoot) /* For the Windows drive change to SystemRoot leaving it as the pwd on that drive... */ trash=directory(pwd) /* Change back to where this script runs from, hopefully the development dir on the server ... */ rc=RunTest(LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot), LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || LDSRexxUtil~LDSFileSpec('PATH', SystemRoot)) /* Test one dir up from SystemRoot considering SystemRoot is still current... */ rc=RunTest(LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || '..', UpOneDir(LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || LDSRexxUtil~LDSFileSpec('PATH', SystemRoot), ArcChar)) rc=RunTest(LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || '*', LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || LDSRexxUtil~LDSFileSpec('PATH', SystemRoot) || '*') rc=RunTest(LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || '..\*', UpOneDir(LDSRexxUtil~LDSFileSpec('DRIVE', SystemRoot) || LDSRexxUtil~LDSFileSpec('PATH', SystemRoot), ArcChar) || '*') end /* when */ /* / */ when ArcChar='/' then do /* Root (Of current drive in DOS land) */ rc=RunTest(ArcChar, ArcChar) end /* when */ /* ? */ otherwise do LDSLogging~Console('Unknown Host OS Arc Char=' || ArcChar || ' Ending Program!') LDSLogging~Logger('Unknown Host OS Arc Char=' || ArcChar || ' Ending Program!') end /* otherwise */ end /* select */ LDSLogging~Console('Ending QualifyTest...') LDSLogging~Logger('Ending QualifyTest...') exit 0 /************************************************************************************/ UpOneDir: procedure INdir=arg(1) ArcChar=arg(2) /* This line works until someone mess's with it, ja hear me?! */ return INdir~left(INdir~left(INdir~length()-1)~lastpos(ArcChar)) /************************************************************************************/ /************************************************************************************/ RunTest: TestCondition=arg(1) ExpectedResult=arg(2) LDSLogging~Console('Running Test Condition=' || TestCondition) LDSLogging~Logger('Running Test Condition=' || TestCondition) TestResult=LDSFileSystem~FullyQualifyFINDfilename(TestCondition) LDSLogging~Console('ExpectedResult=' || ExpectedResult) LDSLogging~Logger('ExpectedResult=' || ExpectedResult) LDSLogging~Console('TestResult=' || TestResult) LDSLogging~Logger('TestResult=' || TestResult) /* Test the result */ if TestResult=ExpectedResult then do LDSLogging~Console('Ending Test Condition=' || TestCondition || ' Result=PASS!') LDSLogging~Logger('Ending Test Condition=' || TestCondition || ' Result=PASS!') end /* if */ else do LDSLogging~Console('Ending Test Condition=' || TestCondition || ' Result=FAIL!') LDSLogging~Logger('Ending Test Condition=' || TestCondition || ' Result=FAIL!') end return 0 /************************************************************************************/ ::requires 'LDSLogging.cls' ::requires 'LDSSystemInfo.cls' ::requires 'LDSParmCheck.cls' ::requires 'LDSRexxUtil.cls' ::requires 'LDSFileSystem.cls' /************************************************************************************/ /* CLASS NAME : ParmCheck */ /* */ /* DESCRIPTION : This program's own parm check subclass */ /* */ /* METHODS : */ /* Init LDSSystemInfo LDSLogging returns *instance or .nil */ /* Test returns Test */ /* ParmCheck Args returns Logical */ /* HelpParms */ /* HelpParmsExtended */ /* SetRXTempDir RXos returns Logical */ /* GetRXTempDir returns RXTempDir */ /* GetFROMPath returns RXTempDir */ /* GetTOPath returns RXTempDir */ /************************************************************************************/ ::class ParmCheck /************************************************************************************/ /* METHOD : Init */ /* */ /* PARAMETERS : LDSSystemInfo, LDSLogging */ /* */ /* DESCRIPTION : Receive handles to LDSSystemInfo and LDSLogging, other setup */ /* */ /* RETURNS : Logical */ /************************************************************************************/ ::method init expose LDSSystemInfo LDSLogging LDSParmCheck Test use arg LDSSystemInfo, LDSLogging /* Set the Test flag dirty */ Test=.nil /* Check the objects we received */ if LDSSystemInfo~Test\='LDSSystemInfo' then do rc=LineOut('STDERR', 'ParmCheck~Init -> Bad LDSSystemInfo Instance') return end if LDSLogging~Test\='LDSLogging' then do rc=LineOut('STDERR', 'ParmCheck~Init -> Bad LDSLogging Instance') return end /* Create an instance of LDSParmCheck */ LDSParmCheck=.LDSParmCheck~new(LDSSystemInfo, LDSLogging) /* Verify the creation of the LDSParmCheck instance */ if result=.nil then do LDSLogging~error('ParmCheck -> Init Error! -> Failed to create LDSParmCheck instance') return .nil end /* if */ /* Get the Temp dir from LDSParmCheck */ self~SetRXTempDir() /* Set the Test flag clean */ Test='ParmCheck' return 1 /************************************************************************************/ /* METHOD : Test */ /* */ /* PARAMETERS : None */ /* */ /* DESCRIPTION : Test the instance */ /* */ /* RETURNS : Test */ /************************************************************************************/ ::method Test expose test return Test /************************************************************************************/ /* METHOD : ParmCheck */ /* */ /* PARAMETERS : Args */ /* */ /* DESCRIPTION : Extends the super ParmCheck method to provide app specific */ /* parm checking */ /* RETURNS : Logical */ /************************************************************************************/ ::method ParmCheck expose LDSSystemInfo LDSLogging LDSParmCheck Args=arg(1) UpArgs=translate(Args) /*DEV*/ LDSLogging~Verbose('In ParmCheck~ParmCheck, Args=' || Args) /* Check in with Object CUR's ParmCheck */ rc=LDSParmCheck~ParmCheck(Args) /* Get the DelimChar for this OS */ DelimChar=LDSParmCheck~GetDelimChar() /* Process the rc of Object CUR's ParmCheck */ select /* HelpParms */ when rc=10 then do self~HelpParms(DelimChar) return 0 end /* when */ /* HelpParmsExtended */ when rc=11 then do self~HelpParmsExtended(DelimChar) return 0 end /* when */ /* Run Program Parm Checks */ otherwise do nop end /* otherwise */ end /* select */ return 1 /************************************************************************************/ /* METHOD : HelpParms */ /* */ /* PARAMETERS : */ /* */ /* DESCRIPTION : Display the program help for parms */ /* */ /* RETURNS : */ /************************************************************************************/ ::method HelpParms PRIVATE expose LDSLogging DelimChar=arg(1) LDSLogging~Console('_____________________') LDSLogging~Console('QualifyTest Help') LDSLogging~Console('') LDSLogging~Console(' This program tests the FullyQualifyFINDfilename method') LDSLogging~Console('Syntax:') LDSLogging~Console(' QualifyTest ['DelimChar'd] ['DelimChar'v] ['DelimChar'??] ['DelimChar'?]') LDSLogging~Console('Where:') LDSLogging~Console(' 'DelimChar'd Specifies a debug run') LDSLogging~Console(' 'DelimChar'v Specifies a verbose run, will display run status') LDSLogging~Console(' 'DelimChar'?? Specifies extended help') LDSLogging~Console(' 'DelimChar'? Specifies to display this text') return /************************************************************************************/ /* METHOD : HelpParmsExtended */ /* */ /* PARAMETERS : */ /* */ /* DESCRIPTION : Display the extended program help for parms */ /* */ /* RETURNS : */ /************************************************************************************/ ::method HelpParmsExtended PRIVATE expose LDSLogging DelimChar=arg(1) LDSLogging~Console('_____________________') LDSLogging~Console('QualifyTest Extended Help') LDSLogging~Console('') return /************************************************************************************/ /* METHOD : SetRXTempDir */ /* */ /* PARAMETERS : RXos */ /* */ /* DESCRIPTION : Define a temp dir for the program to use */ /* */ /* RETURNS : Logical */ /************************************************************************************/ ::method SetRXTempDir PRIVATE expose RXTempDir LDSParmCheck RXTempDir=LDSParmCheck~GetTempDir() return 1 /************************************************************************************/ /* METHOD : GetRXTempDir */ /* */ /* PARAMETERS : None */ /* */ /* DESCRIPTION : Return what this program's temp dir is */ /* */ /* RETURNS : RXTempDir */ /************************************************************************************/ ::method GetRXTempDir expose RXTempDir return RXTempDir