Ignore:
Timestamp:
Sep 2, 2000, 11:08:23 PM (25 years ago)
Author:
bird
Message:

Merged in the Grace branch. New Win32k!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/test/win32ktst.c

    r3829 r4164  
    1 /* $Id: win32ktst.c,v 1.1 2000-07-16 22:18:16 bird Exp $
     1/* $Id: win32ktst.c,v 1.2 2000-09-02 21:08:21 bird Exp $
    22 *
    33 * Win32k test module.
     
    2626    (PVOID)( ( (((unsigned)(flataddr) << 3) & 0xfff80000) | (SEL_LDT_RPL3 << 16) ) | ((unsigned)(flataddr) & 0xffff) )
    2727
     28#define DWORD   ULONG
     29#define WORD    USHORT
     30
    2831/*******************************************************************************
    2932*   Internal Functions                                                         *
    3033*******************************************************************************/
    3134#include <os2.h>
     35#include <exe386.h>
     36
     37#include "devSegDf.h"                   /* Win32k segment definitions. */
    3238
    3339#include "malloc.h"
     
    4248#include "devcmd.h"
    4349#include "os2krnl.h"
     50#include "avl.h"
     51#include "ldr.h"
    4452#include "ldrCalls.h"
    4553#include "test.h"
     
    4755#include "macros.h"
    4856#include "log.h"
     57
     58
     59
    4960
    5061
     
    133144
    134145/*******************************************************************************
     146*   Structures and Typedefs                                                    *
     147*******************************************************************************/
     148#ifndef QS_MTE
     149   /* From OS/2 Toolkit v4.5 (BSEDOS.H) */
     150
     151   /* Global Record structure
     152    * Holds all global system information. Placed first in user buffer
     153    */
     154   typedef struct qsGrec_s {  /* qsGrec */
     155           ULONG         cThrds;
     156           ULONG         c32SSem;
     157           ULONG         cMFTNodes;
     158   }qsGrec_t;
     159
     160   /*
     161    *      System wide MTE information
     162    *      ________________________________
     163    *      |       pNextRec                |----|
     164    *      |-------------------------------|    |
     165    *      |       hmte                    |    |
     166    *      |-------------------------------|    |
     167    *      |       ctImpMod                |    |
     168    *      |-------------------------------|    |
     169    *      |       ctObj                   |    |
     170    *      |-------------------------------|    |
     171    *      |       pObjInfo                |----|----------|
     172    *      |-------------------------------|    |          |
     173    *      |       pName                   |----|----|     |
     174    *      |-------------------------------|    |    |     |
     175    *      |       imported module handles |    |    |     |
     176    *      |          .                    |    |    |     |
     177    *      |          .                    |    |    |     |
     178    *      |          .                    |    |    |     |
     179    *      |-------------------------------| <--|----|     |
     180    *      |       "pathname"              |    |          |
     181    *      |-------------------------------| <--|----------|
     182    *      |       Object records          |    |
     183    *      |       (if requested)          |    |
     184    *      |_______________________________|    |
     185    *                                      <-----
     186    *      NOTE that if the level bit is set to QS_MTE, the base Lib record will be followed
     187    *      by a series of object records (qsLObj_t); one for each object of the
     188    *      module.
     189    */
     190
     191   typedef struct qsLObjrec_s {  /* qsLOrec */
     192           ULONG         oaddr;  /* object address */
     193           ULONG         osize;  /* object size */
     194           ULONG         oflags; /* object flags */
     195   } qsLObjrec_t;
     196
     197   typedef struct qsLrec_s {     /* qsLrec */
     198           void  FAR        *pNextRec;      /* pointer to next record in buffer */
     199           USHORT           hmte;           /* handle for this mte */
     200           USHORT           fFlat;          /* true if 32 bit module */
     201           ULONG            ctImpMod;       /* # of imported modules in table */
     202           ULONG            ctObj;          /* # of objects in module (mte_objcnt)*/
     203           qsLObjrec_t FAR  *pObjInfo;      /* pointer to per object info if any */
     204           UCHAR     FAR    *pName;         /* -> name string following struc */
     205   } qsLrec_t;
     206
     207
     208
     209   /* Pointer Record Structure
     210    *      This structure is the first in the user buffer.
     211    *      It contains pointers to heads of record types that are loaded
     212    *      into the buffer.
     213    */
     214
     215   typedef struct qsPtrRec_s {   /* qsPRec */
     216           qsGrec_t        *pGlobalRec;
     217           void            *pProcRec;      /* ptr to head of process records */
     218           void            *p16SemRec;     /* ptr to head of 16 bit sem recds */
     219           void            *p32SemRec;     /* ptr to head of 32 bit sem recds */
     220           void            *pMemRec;       /* ptr to head of shared mem recs */
     221           qsLrec_t        *pLibRec;       /* ptr to head of mte records */
     222           void            *pShrMemRec;    /* ptr to head of shared mem records */
     223           void            *pFSRec;        /* ptr to head of file sys records */
     224   } qsPtrRec_t;
     225
     226#endif
     227
     228
     229/*******************************************************************************
     230*   Global Variables                                                           *
     231*******************************************************************************/
     232extern BOOL     fInited;                /* malloc.c */
     233int             cObjectsFake = 14;
     234OTE             aKrnlOTE[24];
     235
     236
     237/*******************************************************************************
     238*   External Functions                                                         *
     239*******************************************************************************/
     240#ifndef QS_MTE
     241   /* from OS/2 Toolkit v4.5 */
     242
     243   APIRET APIENTRY DosQuerySysState(ULONG EntityList, ULONG EntityLevel, PID pid,
     244                                    TID tid, PVOID pDataBuf, ULONG cbBuf);
     245    #define QS_MTE         0x0004
     246#endif
     247
     248
     249/*******************************************************************************
    135250*   Internal Functions                                                         *
    136251*******************************************************************************/
    137252void    syntax(void);
     253int     kernelInit(int iTest, int argc, char **argv);
    138254void    workersinit(void);
    139255void    initRPInit(RP32INIT *pRpInit, char *pszInitArgs);
    140256int     tests(int iTest, int argc, char **argv);
    141 int     TestCase1(void);
     257int     TestCase1(int argc, char **argv);
    142258int     TestCase2(void);
    143259int     TestCase3(void);
    144260int     TestCase4(void);
    145261int     TestCase5(void);
     262int     TestCase6(void);
    146263int     CompareOptions(struct options *pOpt);
    147 int     TestCaseExeLoad1(void);
    148 
    149 
    150 /*******************************************************************************
    151 *   Global Variables                                                           *
    152 *******************************************************************************/
    153 extern BOOL     fInited;                /* malloc.c */
    154 const char *    pszInternalRevision = "\r\nInternal revision 14.040_W4";
    155 int             cObjectsFake = 14;
    156 
     264int     TestCaseExeLoad2(void);
    157265
    158266
     
    186294    workersinit();
    187295
     296    /*
     297     * Init Kernel
     298     */
     299    if (!kernelInit(iTest, argc, argv))
     300        return -2;
    188301
    189302    /*
     
    219332{
    220333    printf(
    221         "Win32kTst.exe v%d.%d.%d - Ring 3 testing of win32k.sys\n"
    222         "syntax: Win32kTst.exe <testcase number> [optional arguments]\n",
    223         0,0,4
     334           "Win32kTst.exe v%d.%d.%d - Ring 3 testing of win32k.sys\n"
     335           "syntax: Win32kTst.exe <testcase number> [optional arguments]\n",
     336           0,0,4
    224337           );
    225338}
     
    227340
    228341/**
    229  * Initiate workers (imported kernel functions / vars)
    230  * @status    partially implemented.
    231  * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    232  */
    233 void  workersinit(void)
     342 * test case 1: Load the specified kernel
     343 * other cases: Load running kernel.
     344 * @returns Success indicator. (true/false)
     345 * @param   iTest   Testcase number.
     346 * @param   argc    main argc
     347 * @param   argv    main argv
     348 * @status  completely implemented.
     349 * @author  knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     350 */
     351int     kernelInit(int iTest, int argc, char **argv)
    234352{
    235     DosSetMem(&CODE16START, &CODE16END - &CODE16START, PAG_WRITE | PAG_READ);
    236     DosSetMem(&CODE32START, &CODE32END - &CODE32START, PAG_WRITE | PAG_READ);
     353    static char     achBuffer[1024*256];
     354    char            szError[256];
     355    HMODULE         hmod = NULLHANDLE;
     356    int             rc;
     357    char            szName[CCHMAXPATH];
     358    char *          pszSrcName;
     359    char *          pszTmp;
     360    ULONG           ulAction;
     361    HFILE           hFile;
     362    struct e32_exe* pe32 = (struct e32_exe*)(void*)&achBuffer[0];
     363    qsPtrRec_t *    pPtrRec = (qsPtrRec_t*)(void*)&achBuffer[0];
     364    qsLrec_t *      pLrec;
     365    int             i;
     366    FILESTATUS3     fsts3;
     367
     368    /*
     369     * If not testcase 1, use the running kernel.
     370     */
     371    if (iTest != 1)
     372    {
     373        ULONG   ulBootDrv = 3;
     374        pszSrcName = "c:\\os2krnl";
     375        DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, SSToDS(&ulBootDrv), sizeof(ulBootDrv));
     376        pszSrcName[0] = (char)(ulBootDrv + 'a' - 1);
     377    }
     378    else
     379    {
     380        if (argc < 3)
     381        {
     382            printf("Missing parameter!\n");
     383            return FALSE;
     384        }
     385        pszSrcName = argv[2];
     386    }
     387
     388    /*
     389     * Make a temporary copy of the kernel.
     390     */
     391    if (DosScanEnv("TMP", &pszTmp) != NO_ERROR || pszTmp == NULL)
     392    {
     393        printf("Environment variable TMP is not set.\n");
     394        return FALSE;
     395    }
     396    strcpy(szName, pszTmp);
     397    if (szName[strlen(pszTmp) - 1] != '\\' && szName[strlen(pszTmp) - 1] != '/')
     398        strcat(szName, "\\");
     399    strcat(szName, "os2krnl");
     400    rc = DosCopy(pszSrcName, szName, DCPY_EXISTING);
     401    if (rc != NO_ERROR)
     402    {
     403        printf("Failed to copy %s to %s.\n", pszSrcName, szName);
     404        return FALSE;
     405    }
     406    if (DosQueryPathInfo(szName, FIL_STANDARD, &fsts3, sizeof(fsts3)) != NO_ERROR
     407        ||  !(fsts3.attrFile = FILE_ARCHIVED)
     408        ||  DosSetPathInfo(szName, FIL_STANDARD, &fsts3, sizeof(fsts3), 0) != NO_ERROR
     409        )
     410    {
     411        printf("Failed to set attributes for %s.\n", szName);
     412        return FALSE;
     413    }
     414
     415    /*
     416     * Patch the kernel.
     417     *      Remove the entrypoint.
     418     */
     419    ulAction = 0;
     420    rc = DosOpen(szName, &hFile, &ulAction, 0, FILE_NORMAL,
     421                 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
     422                 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
     423                 NULL);
     424    if (rc != NO_ERROR)
     425    {
     426        printf("Failed to open temporary kernel file. rc = %d\n", rc);
     427        return FALSE;
     428    }
     429    rc = DosRead(hFile, &achBuffer[0], 0x200, &ulAction);
     430    if (rc != NO_ERROR)
     431    {
     432        DosClose(hFile);
     433        printf("Failed to read LX header from temporary kernel file.\n");
     434        return FALSE;
     435    }
     436    pe32 = (struct e32_exe*)(void*)&achBuffer[*(unsigned long*)(void*)&achBuffer[0x3c]];
     437    if (*(PUSHORT)pe32->e32_magic != E32MAGIC)
     438    {
     439        DosClose(hFile);
     440        printf("Failed to read LX header from temporary kernel file (2).\n");
     441        return FALSE;
     442    }
     443    pe32->e32_eip = 0;
     444    pe32->e32_startobj = 0;
     445    pe32->e32_mflags &= ~(E32LIBTERM | E32LIBINIT);
     446    if ((rc = DosSetFilePtr(hFile, *(unsigned long*)(void*)&achBuffer[0x3c], FILE_BEGIN, &ulAction)) != NO_ERROR
     447        || (rc = DosWrite(hFile, pe32, sizeof(struct e32_exe), &ulAction)) != NO_ERROR)
     448    {
     449        DosClose(hFile);
     450        printf("Failed to write patched LX header to temporary kernel file.\n");
     451        return FALSE;
     452    }
     453    DosClose(hFile);
     454
     455    /*
     456     * Load the module.
     457     */
     458    rc = DosLoadModule(szError, sizeof(szError), szName, SSToDS(&hmod));
     459    if (rc != NO_ERROR && (rc != ERROR_INVALID_PARAMETER && hmod == NULLHANDLE))
     460    {
     461        printf("Failed to load OS/2 kernel image %s.");
     462        return FALSE;
     463    }
     464
     465    /*
     466     * Get object information.
     467     */
     468    rc = DosQuerySysState(QS_MTE, QS_MTE, 0L, 0L, pPtrRec, sizeof(achBuffer));
     469    if (rc != NO_ERROR)
     470    {
     471        printf("DosQuerySysState failed with rc=%d.\n", rc);
     472        return FALSE;
     473    }
     474
     475    pLrec = pPtrRec->pLibRec;
     476    while (pLrec != NULL)
     477    {
     478        /*
     479         * Bug detected in OS/2 FP13. Probably a problem which occurs
     480         * in _LDRSysMteInfo when qsCheckCache is calle before writing
     481         * object info. The result is that the cache flushed and the
     482         * attempt of updating the qsLrec_t next and object pointer is
     483         * not done. This used to work earlier and on Aurora AFAIK.
     484         *
     485         * The fix for this problem is to check if the pObjInfo is NULL
     486         * while the number of objects isn't 0 and correct this. pNextRec
     487         * will also be NULL at this time. This will be have to corrected
     488         * before we exit the loop or moves to the next record.
     489         * There is also a nasty alignment of the object info... Hope
     490         * I got it right. (This aligment seems new to FP13.)
     491         */
     492        if (pLrec->pObjInfo == NULL /*&& pLrec->pNextRec == NULL*/ && pLrec->ctObj > 0)
     493            {
     494            pLrec->pObjInfo = (qsLObjrec_t*)(void*)(
     495                (char*)(void*)pLrec
     496                + ((sizeof(qsLrec_t)                            /* size of the lib record */
     497                   + pLrec->ctImpMod * sizeof(short)            /* size of the array of imported modules */
     498                   + strlen((char*)(void*)pLrec->pName) + 1     /* size of the filename */
     499                   + 3) & ~3));                                 /* the size is align on 4 bytes boundrary */
     500            pLrec->pNextRec = (qsLrec_t*)(void*)((char*)(void*)pLrec->pObjInfo
     501                                                 + sizeof(qsLObjrec_t) * pLrec->ctObj);
     502            }
     503        if (pLrec->hmte == hmod)
     504            break;
     505
     506        /*
     507         * Next record
     508         */
     509        pLrec = (qsLrec_t*)pLrec->pNextRec;
     510    }
     511
     512    if (pLrec == NULL)
     513    {
     514        printf("DosQuerySysState(os2krnl): not found\n");
     515        return FALSE;
     516    }
     517    if (pLrec->pObjInfo == NULL)
     518    {
     519        printf("DosQuerySysState(os2krnl): no object info\n");
     520        return FALSE;
     521    }
     522
     523    /*
     524     * Fill the aKrnlOTE array.
     525     */
     526    for (i = 0; i < pLrec->ctObj; i++)
     527    {
     528        aKrnlOTE[i].ote_size    = pLrec->pObjInfo[i].osize;
     529        aKrnlOTE[i].ote_base    = pLrec->pObjInfo[i].oaddr;
     530        aKrnlOTE[i].ote_flags   = pLrec->pObjInfo[i].oflags;
     531        aKrnlOTE[i].ote_pagemap = i > 0 ? aKrnlOTE[i-1].ote_pagemap + aKrnlOTE[i-1].ote_mapsize : 0;
     532        aKrnlOTE[i].ote_mapsize = (pLrec->pObjInfo[i].osize + 0x0FFF) / 0x1000;
     533        aKrnlOTE[i].ote_sel     = (USHORT)FlatToSel(pLrec->pObjInfo[i].oaddr);
     534        aKrnlOTE[i].ote_hob     = 0;
     535    }
     536    cObjectsFake = pLrec->ctObj;
     537
     538    return TRUE;
    237539}
    238540
     
    273575    switch (iTest)
    274576    {
    275         case 1:     rc = TestCase1();   break;
     577        case 1:     rc = TestCase1(argc, argv);   break;
    276578        case 2:     rc = TestCase2();   break;
    277579        case 3:     rc = TestCase3();   break;
    278         case 4:     rc = TestCase4();   break;
    279         case 5:     rc = TestCase5();   break;
    280580
    281581        default:
     
    294594/**
    295595 * Test case 1.
    296  * Checks that default initiation works fine for Aurora SMP kernels.
     596 * Checks that default initiation works fine for a given kernel.
     597 *
     598 * Syntax:  win32ktst.exe 1 <os2krnl> <majorver> <minorver> <build> <kerneltype: S|U|4> <buildtype: A|H|R> [os2krnl.sym]
    297599 *
    298600 * @sketch  Create init packet with no arguments.
     
    305607 * @author  knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    306608 */
    307 int TestCase1(void)
     609int TestCase1(int argc, char **argv)
    308610{
     611    static char szInitArgs[CCHMAXPATH + 10];
    309612    int         rc = 1;
    310613    RP32INIT    rpinit;
    311614
     615    /* verify argument count */
     616    if (argc < 8 || argc > 9)
     617    {
     618        printf("Invalid parameter count for testcase 1.\n");
     619        return ERROR_INVALID_PARAMETER;
     620    }
     621
    312622    /* init fake variabels */
    313     pszInternalRevision ="\r\nInternal revision 14.040_SMP";
    314     cObjectsFake = 15;
    315     _usFakeVerMajor = 20;
    316     _usFakeVerMinor = 45;
     623    _usFakeVerMajor = (USHORT)atoi(argv[3]);
     624    _usFakeVerMinor = (USHORT)atoi(argv[4]);
     625
     626    /* make init string */
     627    strcpy(szInitArgs, "-w3");
     628    if (argc >= 9)
     629        strcat(strcat(szInitArgs, " -S:"), argv[8]);
    317630
    318631    /* $elf */
    319     initRPInit(SSToDS(&rpinit), "-w3");
     632    initRPInit(SSToDS(&rpinit), szInitArgs);
    320633    rc = InitElf(&rpinit);              /* no SSToDS! */
    321634    printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
     
    323636    {
    324637        /* $win32k */
    325         initRPInit(SSToDS(&rpinit), "-w3");
     638        initRPInit(SSToDS(&rpinit), szInitArgs);
    326639        rc = InitWin32k(&rpinit);       /* no SSToDS! */
    327640        printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
     
    329642        {
    330643            struct options opt = DEFAULT_OPTION_ASSIGMENTS;
    331             opt.fKernel = KF_SMP;
    332             opt.ulBuild = 14040;
    333             opt.usVerMajor = 20;
    334             opt.usVerMinor = 45;
    335644            opt.ulInfoLevel = 3;
     645            opt.fKernel = (argv[6][0] == 'S' ? KF_SMP : (argv[6][0] == '4' ? KF_W4 | KF_UNI : KF_UNI))
     646                            | (argv[7][0] == 'A' || argv[7][0] == 'H' ? KF_DEBUG : 0);
     647            opt.ulBuild = atoi(argv[5]);
     648            opt.usVerMajor = (USHORT)atoi(argv[3]);
     649            opt.usVerMinor = (USHORT)atoi(argv[4]);
    336650
    337651            rc = CompareOptions(SSToDS(&opt));
    338             if (rc == NO_ERROR)
    339             {
    340                 rc = TestCaseExeLoad1();
    341             }
    342652        }
    343653        else
     
    350660}
    351661
    352 
    353662/**
    354663 * Test case 2.
    355  * Checks that default initiation works fine for Aurora UNI kernels.
     664 * Checks that all parameters are read correctly (1).
    356665 *
    357666 * @sketch  Create init packet with no arguments.
     
    368677    int         rc = 1;
    369678    RP32INIT    rpinit;
    370 
    371     /* init fake variabels */
    372     pszInternalRevision ="\r\nInternal revision 14.040_UNI";
    373     cObjectsFake = 14;
    374     _usFakeVerMajor = 20;
    375     _usFakeVerMinor = 45;
     679    char *      pszInitArgs = "-C1 -L:E -Verbose -Elf:Yes -Pe:Mixed -Script:Yes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000";
     680
     681    options.fLogging = TRUE;
    376682
    377683    /* $elf */
    378     initRPInit(SSToDS(&rpinit), "");
     684    initRPInit(SSToDS(&rpinit), pszInitArgs);
    379685    rc = InitElf(&rpinit);              /* no SSToDS! */
    380686    printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
     
    382688    {
    383689        /* $win32k */
    384         initRPInit(SSToDS(&rpinit), "");
     690        initRPInit(SSToDS(&rpinit), pszInitArgs);
    385691        rc = InitWin32k(&rpinit);       /* no SSToDS! */
    386692        printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
     
    388694        {
    389695            struct options opt = DEFAULT_OPTION_ASSIGMENTS;
    390             opt.fKernel = KF_UNI;
    391             opt.ulBuild = 14040;
    392             opt.usVerMajor = 20;
    393             opt.usVerMinor = 45;
     696            opt.cbSwpHeapInit   = 512000;
     697            opt.cbSwpHeapMax    = 4096000;
     698            opt.cbResHeapInit   = 0256000;
     699            opt.cbResHeapMax    = 0x100000;
     700            opt.fElf            = TRUE;
     701            opt.fUNIXScript     = TRUE;
     702            opt.fPE             = FLAGS_PE_MIXED;
     703            opt.fQuiet          = FALSE;
     704            opt.fLogging        = TRUE;
     705            opt.usCom           = OUTPUT_COM1;
     706            opt.ulInfoLevel     = INFOLEVEL_INFOALL;
    394707
    395708            rc = CompareOptions(SSToDS(&opt));
     709            if (rc == NO_ERROR)
     710            {
     711                 rc = TestCaseExeLoad2();
     712            }
    396713        }
    397714        else
     
    404721}
    405722
    406 
    407723/**
    408724 * Test case 3.
    409  * Checks that default initiation works fine for Warp FP13 kernel.
     725 * Checks that all parameters are read correctly (1).
    410726 *
    411727 * @sketch  Create init packet with no arguments.
     
    422738    int         rc = 1;
    423739    RP32INIT    rpinit;
    424 
    425     /* init fake variabels */
    426     pszInternalRevision ="\r\nInternal revision 14.040_W4";
    427     cObjectsFake = 14;
    428     _usFakeVerMajor = 20;
    429     _usFakeVerMinor = 45;
    430 
    431     /* $elf */
    432     initRPInit(SSToDS(&rpinit), "");
    433     rc = InitElf(&rpinit);              /* no SSToDS! */
    434     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
    435     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
    436     {
    437         /* $win32k */
    438         initRPInit(SSToDS(&rpinit), "");
    439         rc = InitWin32k(&rpinit);       /* no SSToDS! */
    440         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
    441         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
    442         {
    443             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
    444             opt.fKernel = KF_UNI | KF_W4;
    445             opt.ulBuild = 14040;
    446             opt.usVerMajor = 20;
    447             opt.usVerMinor = 45;
    448 
    449             rc = CompareOptions(SSToDS(&opt));
    450         }
    451         else
    452             printf("!failed!\n");
    453     }
    454     else
    455         printf("!failed!\n");
    456 
    457     return rc;
    458 }
    459 
    460 
    461 /**
    462  * Test case 4.
    463  * Checks that default initiation works fine for Aurora SMP kernels.
    464  *
    465  * @sketch  Create init packet with no arguments.
    466  *          Initiate elf$
    467  *          Create init packet with no arguments.
    468  *          Initiate win32k$
    469  * @returns 0 on success.
    470  *          1 on failure.
    471  * @status  completely implemented.
    472  * @author  knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    473  */
    474 int TestCase4(void)
    475 {
    476     int         rc = 1;
    477     RP32INIT    rpinit;
    478 
    479     /* init fake variabels */
    480     pszInternalRevision ="\r\nInternal revision 9.036";
    481     cObjectsFake = 14;
    482     _usFakeVerMajor = 20;
    483     _usFakeVerMinor = 40;
    484 
    485     /* $elf */
    486     initRPInit(SSToDS(&rpinit), "");
    487     rc = InitElf(&rpinit);              /* no SSToDS! */
    488     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
    489     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
    490     {
    491         /* $win32k */
    492         initRPInit(SSToDS(&rpinit), "");
    493         rc = InitWin32k(&rpinit);       /* no SSToDS! */
    494         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
    495         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
    496         {
    497             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
    498             opt.fKernel     = KF_UNI;
    499             opt.ulBuild     = 9036;
    500             opt.usVerMajor  = 20;
    501             opt.usVerMinor  = 40;
    502 
    503             rc = CompareOptions(SSToDS(&opt));
    504         }
    505         else
    506             printf("!failed!\n");
    507     }
    508     else
    509         printf("!failed!\n");
    510 
    511     return rc;
    512 }
    513 
    514 
    515 /**
    516  * Test case 5.
    517  * Checks that all parameters are read correctly (1) (Warp FP13 kernel).
    518  *
    519  * @sketch  Create init packet with no arguments.
    520  *          Initiate elf$
    521  *          Create init packet with no arguments.
    522  *          Initiate win32k$
    523  * @returns 0 on success.
    524  *          1 on failure.
    525  * @status  completely implemented.
    526  * @author  knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    527  */
    528 int TestCase5(void)
    529 {
    530     int         rc = 1;
    531     RP32INIT    rpinit;
    532     char *      pszInitArgs = "-C1 -L:N -Verbose -Quiet -Elf:Yes -Pe:Mixed -Script:No -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000";
    533 
    534     /* init fake variabels */
    535     pszInternalRevision ="\r\nInternal revision 14.040_W4";
    536     cObjectsFake = 14;
    537     _usFakeVerMajor = 20;
    538     _usFakeVerMinor = 45;
     740    char *      pszInitArgs = "-C1 -L:N -Verbose -Quiet -Elf:Yes -Pe:PE -Script:Yes -Rexx:NES -Java:NYes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000";
    539741
    540742    /* $elf */
     
    551753        {
    552754            struct options opt = DEFAULT_OPTION_ASSIGMENTS;
    553             opt.fKernel         = KF_UNI | KF_W4;
    554             opt.ulBuild         = 14040;
    555             opt.usVerMajor      = 20;
    556             opt.usVerMinor      = 45;
    557755            opt.cbSwpHeapInit   = 512000;
    558756            opt.cbSwpHeapMax    = 4096000;
     
    560758            opt.cbResHeapMax    = 0x100000;
    561759            opt.fElf            = TRUE;
    562             opt.fUNIXScript     = FALSE;
    563             opt.fPE             = FLAGS_PE_MIXED;
     760            opt.fUNIXScript     = TRUE;
     761            opt.fJava           = FALSE;
     762            opt.fREXXScript     = FALSE;
     763            opt.fPE             = FLAGS_PE_PE;
    564764            opt.fQuiet          = TRUE;
    565765            opt.fLogging        = FALSE;
     
    568768
    569769            rc = CompareOptions(SSToDS(&opt));
     770            if (rc == NO_ERROR)
     771            {
     772                 rc = TestCaseExeLoad2();
     773            }
    570774        }
    571775        else
     
    577781    return rc;
    578782}
     783
    579784
    580785/**
     
    598803    if (options.fLogging != pOpt->fLogging)
    599804        printf("fLogging = %d - should be %d\n", options.fLogging, pOpt->fLogging, rc++);
    600     if (options.fKernel != pOpt->fKernel)
    601         printf("fKernel = %d - should be %d\n", options.fKernel, pOpt->fKernel, rc++);
    602     if (options.ulBuild != pOpt->ulBuild)
    603         printf("ulBuild = %d - should be %d\n", options.ulBuild, pOpt->ulBuild, rc++);
    604     if (options.usVerMajor != pOpt->usVerMajor)
    605         printf("usVerMajor = %d - should be %d\n", options.usVerMajor, pOpt->usVerMajor, rc++);
    606     if (options.usVerMinor != pOpt->usVerMinor)
    607         printf("usVerMinor = %d - should be %d\n", options.usVerMinor, pOpt->usVerMinor, rc++);
     805    if (pOpt->ulBuild != ~0UL)
     806    {
     807        if (options.fKernel != pOpt->fKernel)
     808            printf("fKernel = %d - should be %d\n", options.fKernel, pOpt->fKernel, rc++);
     809        if (options.ulBuild != pOpt->ulBuild)
     810            printf("ulBuild = %d - should be %d\n", options.ulBuild, pOpt->ulBuild, rc++);
     811        if (options.usVerMajor != pOpt->usVerMajor)
     812            printf("usVerMajor = %d - should be %d\n", options.usVerMajor, pOpt->usVerMajor, rc++);
     813        if (options.usVerMinor != pOpt->usVerMinor)
     814            printf("usVerMinor = %d - should be %d\n", options.usVerMinor, pOpt->usVerMinor, rc++);
     815    }
    608816    if (options.fPE != pOpt->fPE)
    609817        printf("fPE = %d - should be %d\n", options.fPE, pOpt->fPE, rc++);
     
    633841
    634842
    635 
    636 
    637843/**
    638844 * Simulates a executable loading (no errors).
     
    647853 * @remark
    648854 */
    649 int TestCaseExeLoad1(void)
     855int TestCaseExeLoad2(void)
    650856{
    651857    APIRET rc;
     858    int    cch;
     859    char * psz;
    652860
    653861    /*
     
    658866     * Do the real execution.
    659867     */
    660     printf("--- TestcaseExeLoad1 - loading win32ktst.exe (LX image) ----\n");
     868    printf("--- TestcaseExeLoad2 - loading win32ktst.exe (LX image) ----\n");
    661869    rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "win32ktst.exe");
    662870    if (rc == NO_ERROR)
    663871    {
    664         printf("--- TestcaseExeLoad1 - loading libconv.exe (LX image) ----\n");
     872        psz = "BIN\\DEBUG\\LIBCONV.EXE\0";
     873        printf("--- TestcaseExeLoad2 - loading libconv.exe (LX image) ----\n");
    665874        rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "bin\\debug\\libconv.exe");
     875        if (rc == NO_ERROR)
     876        {
     877            #if 0 //not implemented by CalltkExecPgm...???
     878            /* check result */
     879            if (memcmp(achTkExecPgmArguments, psz, strlen(psz) + 1) != 0)
     880            {
     881                rc  = ERROR_BAD_ARGUMENTS;
     882                printf("Bad Arguments! (%s)\n", achTkExecPgmArguments);
     883            }
     884            #else
     885            psz = psz;
     886            #endif
     887        }
    666888    }
    667889
    668890    if (rc == NO_ERROR)
    669891    {
    670         printf("--- TestcaseExeLoad1 - loading rexx\\tst.cmd (REXX script) ----\n");
    671         rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "rexx\\tst.cmd");
     892        psz = "REXX\\TST.RX\0OriginalArgument1 OriginalArgument2\0OriginalArgument3\0";
     893        printf("--- TestcaseExeLoad2 - loading rexx\\tst.rx (REXX script) ----\n");
     894        rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "rexx\\tst.rx");
     895        if (rc == NO_ERROR)
     896        {
     897            /* check result */
     898            psz = "REXX\\TST.RX OriginalArgument1 OriginalArgument2\0OriginalArgument3\0";
     899            cch = strlen(psz);
     900            if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
     901            {
     902                rc  = ERROR_BAD_ARGUMENTS;
     903                printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
     904            }
     905        }
    672906    }
    673907
    674908    if (rc == NO_ERROR)
    675909    {
    676         printf("--- TestcaseExeLoad1 - loading SOL.EXE (PE image) ----\n");
    677         rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "e:\\Win32Prog\\Sol\\Sol.exe");
     910        psz = "TEST\\TST.SH\0OrgArg1 OrgArg2\0OrgArg3\0";
     911        printf("--- TestcaseExeLoad2 - loading test\\tst.sh (UNIX shell script) ----\n");
     912        rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "test\\tst.sh");
     913        if (rc == NO_ERROR)
     914        {
     915            /* check result */
     916            psz = "TEST\\TST.SH OrgArg1 OrgArg2\0OrgArg3\0";
     917            cch = strlen(psz);
     918            if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
     919            {
     920                rc  = ERROR_BAD_ARGUMENTS;
     921                printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
     922            }
     923        }
     924    }
     925
     926    if (rc == NO_ERROR)
     927    {
     928        psz = "TEST\\TST2.SH\0OrgArg1 OrgArg2\0OrgArg3\0";
     929        printf("--- TestcaseExeLoad2 - loading test\\tst2.sh (UNIX shell script) ----\n");
     930        rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "test\\tst2.sh");
     931        if (rc == NO_ERROR)
     932        {
     933            /* check result */
     934            psz = "-arg1 -arg2 -arg3 TEST\\TST2.SH OrgArg1 OrgArg2\0OrgArg3\0";
     935            cch = strlen(psz) + 1;
     936            if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
     937            {
     938                rc  = ERROR_BAD_ARGUMENTS;
     939                printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
     940            }
     941        }
     942    }
     943
     944    if (rc == NO_ERROR)
     945    {
     946        psz = "E:\\WIN32PROG\\SOL\\SOL.EXE\0";
     947        printf("--- TestcaseExeLoad2 - loading SOL.EXE (PE image) ----\n");
     948        rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "e:\\Win32Prog\\Sol\\Sol.exe");
     949        if (rc == NO_ERROR)
     950        {
     951            /* check result */
     952            cch = strlen(psz) + 1 + 1;
     953            if (memcmp(achTkExecPgmArguments, psz, cch) != 0)
     954            {
     955                rc  = ERROR_BAD_ARGUMENTS;
     956                printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
     957            }
     958        }
    678959    }
    679960
     
    683964    return rc;
    684965}
     966
Note: See TracChangeset for help on using the changeset viewer.