Changeset 3584


Ignore:
Timestamp:
Sep 3, 2007, 12:46:37 AM (18 years ago)
Author:
bird
Message:

fixed the testcases.

Location:
trunk/kStuff/kLdr
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/kLdr/Makefile.kmk

    r3581 r3584  
    2828SUB_DEPTH = ..
    2929include $(PATH_KBUILD)/subheader.kmk
     30
     31#todo: include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
    3032
    3133#
  • trunk/kStuff/kLdr/testcase/Makefile.kmk

    r2967 r3584  
    2626
    2727# generate rules.
    28 DEPTH = ../..
    29 include $(PATH_KBUILD)/header.kmk
    30 
    31 DEFAULT_PASSES := $(filter-out PACKING, $(DEFAULT_PASSES))
     28DEPTH ?= ../../..
     29SUB_DEPTH = ../..
     30include $(PATH_KBUILD)/subheader.kmk
    3231
    3332
     
    7877 endif
    7978endif
    80 TEMPLATE_TST_INCS = . ..
     79TEMPLATE_TST_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
    8180
    8281
     
    129128 endif
    130129endif
    131 TEMPLATE_TSTBARE_INCS = . ..
     130TEMPLATE_TSTBARE_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
    132131
    133132TEMPLATE_TSTBAREPROG = Bare bone testcase program template
     
    274273else
    275274DLLS += tst-3
    276 LIBRARIES.win = tst-3-imp
    277 LIBRARIES.os2 = tst-3-imp
     275LIBRARIES.win += tst-3-imp
     276LIBRARIES.os2 += tst-3-imp
    278277endif
    279278
     
    299298
    300299# generate rules.
    301 include $(PATH_KBUILD)/footer.kmk
    302 
     300include $(PATH_KBUILD)/subfooter.kmk
     301
  • trunk/kStuff/kLdr/testcase/tst-0-driver.c

    r2965 r3584  
    2929*   Header Files                                                               *
    3030*******************************************************************************/
    31 #include <kLdr.h>
    3231#include "tst.h"
    3332#include <stdarg.h>
     
    7675    char szBuf[512];
    7776    char *psz;
    78     size_t cch;
     77    KSIZE cch;
    7978    HKLDRMOD hMod;
    8079    int rc;
     
    145144            szBuf[cch + 2] = '\0';
    146145            rc = kLdrDyldGetName(hMod2, szBuf, cch);
    147             if (rc == KLDR_ERR_BUFFER_OVERFLOW)
     146            if (rc == KERR_BUFFER_OVERFLOW)
    148147            {
    149148                if (!szBuf[0])
     
    155154            }
    156155            else
    157                 Failure("kLdrDyldGetName(\"tst-0-d\",,,) -> rc=%d (%#x) instead of KLDR_ERR_BUFFER_OVERFLOW\n", rc, rc);
     156                Failure("kLdrDyldGetName(\"tst-0-d\",,,) -> rc=%d (%#x) instead of KERR_BUFFER_OVERFLOW\n", rc, rc);
    158157
    159158            /* check that we can query the module by the returned name. */
     
    183182            szBuf[cch + 2] = '\0';
    184183            rc = kLdrDyldGetFilename(hMod2, szBuf, cch);
    185             if (rc == KLDR_ERR_BUFFER_OVERFLOW)
     184            if (rc == KERR_BUFFER_OVERFLOW)
    186185            {
    187186                if (!szBuf[0])
     
    193192            }
    194193            else
    195                 Failure("kLdrDyldGetFilename(\"tst-0-d\",,,) -> rc=%d (%#x) instead of KLDR_ERR_BUFFER_OVERFLOW\n", rc, rc);
     194                Failure("kLdrDyldGetFilename(\"tst-0-d\",,,) -> rc=%d (%#x) instead of KERR_BUFFER_OVERFLOW\n", rc, rc);
    196195
    197196            /* check that we can query the module by the returned filename. */
     
    252251        if (!g_cErrors)
    253252        {
    254             uintptr_t uValue;
    255             uint32_t fKind;
     253            KUPTR uValue;
     254            KU32 fKind;
    256255
    257256            fKind = 0xffeeffee;
    258             uValue = ~(uintptr_t)42;
    259             rc = kLdrDyldQuerySymbol(hMod, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), &uValue, &fKind);
    260             if (!rc)
    261             {
    262                 if (uValue == ~(uintptr_t)42)
     257            uValue = ~(KUPTR)42;
     258            rc = kLdrDyldQuerySymbol(hMod, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), NULL, &uValue, &fKind);
     259            if (!rc)
     260            {
     261                if (uValue == ~(KUPTR)42)
    263262                    Failure("kLdrDyldQuerySymbol(\"tst-0-a\",,\"FuncA\",): uValue wasn't set.\n");
    264263                if (fKind == 0xffeeffee)
     
    289288                if (!rc)
    290289                {
    291                     uintptr_t offSegment;
    292                     uint32_t iSegment;
     290                    KUPTR offSegment;
     291                    KU32 iSegment;
    293292
    294293                    if (hMod3 != hMod)
     
    316315                    iSegment = 0x42424242;
    317316                    offSegment = 0x87654321;
    318                     rc = kLdrDyldFindByAddress(~(uintptr_t)16, &hMod3, &iSegment, &offSegment);
     317                    rc = kLdrDyldFindByAddress(~(KUPTR)16, &hMod3, &iSegment, &offSegment);
    319318                    if (!rc)
    320319                        Failure("negative kLdrDyldFindByAddress test returned successfully!\n");
    321                     if (iSegment != ~(uint32_t)0)
     320                    if (iSegment != ~(KU32)0)
    322321                        Failure("negative kLdrDyldFindByAddress: bad iSegment=%#x\n", iSegment);
    323                     if (offSegment != ~(uintptr_t)0)
     322                    if (offSegment != ~(KUPTR)0)
    324323                        Failure("negative kLdrDyldFindByAddress: bad offSegment=%p\n", (void *)offSegment);
    325324                    if (hMod3 != NIL_HKLDRMOD)
     
    334333
    335334            fKind = 0xffeeffee;
    336             uValue = ~(uintptr_t)42;
    337             rc = kLdrDyldQuerySymbol(hMod2, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncD"), &uValue, &fKind);
    338             if (!rc)
    339             {
    340                 if (uValue == ~(uintptr_t)42)
     335            uValue = ~(KUPTR)42;
     336            rc = kLdrDyldQuerySymbol(hMod2, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncD"), NULL, &uValue, &fKind);
     337            if (!rc)
     338            {
     339                if (uValue == ~(KUPTR)42)
    341340                    Failure("kLdrDyldQuerySymbol(\"tst-0-d\",,\"FuncD\",): uValue wasn't set.\n");
    342341                if (fKind == 0xffeeffee)
     
    407406        HKLDRMOD hModC;
    408407        int (*pfnFuncC)(void);
    409         uintptr_t uValue;
     408        KUPTR uValue;
    410409
    411410        rc = kLdrDyldLoad("tst-0-a", NULL, NULL, KLDRDYLD_SEARCH_HOST, 0, &hModA, NULL, 0);
     
    426425        if (!rc)
    427426        {
    428             rc = kLdrDyldQuerySymbol(hModA, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), &uValue, NULL);
     427            rc = kLdrDyldQuerySymbol(hModA, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), NULL, &uValue, NULL);
    429428            if (!rc)
    430429                pfnFuncA = (int (*)(void))uValue;
     
    434433        if (!rc)
    435434        {
    436             rc = kLdrDyldQuerySymbol(hModB, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncB"), &uValue, NULL);
     435            rc = kLdrDyldQuerySymbol(hModB, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncB"), NULL, &uValue, NULL);
    437436            if (!rc)
    438437                pfnFuncB = (int (*)(void))uValue;
     
    442441        if (!rc)
    443442        {
    444             rc = kLdrDyldQuerySymbol(hModC, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncC"), &uValue, NULL);
     443            rc = kLdrDyldQuerySymbol(hModC, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncC"), NULL, &uValue, NULL);
    445444            if (!rc)
    446445                pfnFuncC = (int (*)(void))uValue;
  • trunk/kStuff/kLdr/testcase/tst-3-driver.c

    r3579 r3584  
    2929*   Header Files                                                               *
    3030*******************************************************************************/
    31 #include <kLdr.h>
    3231#include "tst.h"
     32#include <k/kErr.h>
     33
    3334#include <stdarg.h>
    3435#include <stdio.h>
     
    8687 * Callback for resolving the Tst3Ext import.
    8788 */
    88 static int GetImport(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_t cchSymbol,
    89                      const char *pszVersion, PKLDRADDR puValue, uint32_t *pfKind, void *pvUser)
     89static int GetImport(PKLDRMOD pMod, KU32 iImport, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol,
     90                     const char *pszVersion, PKLDRADDR puValue, KU32 *pfKind, void *pvUser)
    9091{
    9192    if (*pfKind != KLDRSYMKIND_REQ_FLAT)
     
    9596        ||  !strncmp(pchSymbol, "_Tst3Ext", strlen("_Tst3Ext")))
    9697    {
    97         *puValue = (uintptr_t)&Tst3Ext;
     98        *puValue = (KUPTR)&Tst3Ext;
    9899        *pfKind = KLDRSYMKIND_CODE | (sizeof(pfKind) == 4 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT);
    99100        return 0;
     
    124125    /* get bits. */
    125126    cbImage = kLdrModSize(pMod);
    126     pvBits = malloc((size_t)cbImage + 0xfff);
     127    pvBits = malloc((KSIZE)cbImage + 0xfff);
    127128    if (pvBits)
    128129    {
    129         void *pvBits2 = (void *)( ((uintptr_t)pvBits + 0xfff) & ~(uintptr_t)0xfff );
    130 
    131         KLDRADDR BaseAddress = (uintptr_t)pvBits2;
     130        void *pvBits2 = (void *)( ((KUPTR)pvBits + 0xfff) & ~(KUPTR)0xfff );
     131
     132        KLDRADDR BaseAddress = (KUPTR)pvBits2;
    132133        rc = kLdrModGetBits(pMod, pvBits2, BaseAddress, GetImport, NULL);
    133134        if (!rc)
     
    143144            if (!rc)
    144145            {
    145                 int (*pfnEntryPoint)(int) = (int (*)(int)) ((uintptr_t)EntryPoint);
     146                int (*pfnEntryPoint)(int) = (int (*)(int)) ((KUPTR)EntryPoint);
    146147                rc = pfnEntryPoint(42);
    147148                if (rc == 42)
  • trunk/kStuff/kLdr/testcase/tst.h

    r2965 r3584  
    11/* $Id$ */
    22/** @file
     3 * kLdr testcase header.
     4 */
     5
     6/*
     7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
    38 *
    4  * kLdr testcase.
     9 * This file is part of kStuff.
    510 *
    6  * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net>
     11 * kStuff is free software; you can redistribute it and/or
     12 * modify it under the terms of the GNU Lesser General Public
     13 * License as published by the Free Software Foundation; either
     14 * version 2.1 of the License, or (at your option) any later version.
    715 *
     16 * kStuff is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19 * Lesser General Public License for more details.
    820 *
    9  * This file is part of kLdr.
    10  *
    11  * kLdr is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
    14  * (at your option) any later version.
    15  *
    16  * kLdr is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
    22  * along with kLdr; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     21 * You should have received a copy of the GNU Lesser General Public
     22 * License along with kStuff; if not, write to the Free Software
     23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    2424 *
    2525 */
    2626
     27#ifndef ___tst_h___
     28#define ___tst_h___
    2729
    28 #ifndef __tst_h__
    29 #define __tst_h__
     30#include <k/kLdr.h>
     31#include <k/kHlp.h>
    3032
    31 #include "../kLdr.h"
    32 #include "../kLdrHlp.h"
    33 
    34 
    35 #if defined(__OS2__) || defined(__WIN__) || defined(__NT__)
     33#if K_OS == K_OS_OS2 \
     34 || K_OS == K_OS_WINDOWS
    3635# define MY_EXPORT(type) __declspec(dllexport) type
    3736/*# define MY_IMPORT(type) extern __declspec(dllimport) type*/
     
    4241#endif
    4342
    44 #if defined(__OS2__) || defined(__DARWIN__)
     43#if K_OS == K_OS_OS2 \
     44 || K_OS == K_OS_DARWIN
    4545# define MY_NAME(a) "_" a
    4646#else
  • trunk/kStuff/kLdr/testcase/tstDllMain.c

    r2965 r3584  
    3131#include "tst.h"
    3232
    33 #ifdef __OS2__
     33#if K_OS == K_OS_OS2
    3434# define INCL_BASE
    3535# include <os2.h>
    3636# include <string.h>
    3737
    38 #elif defined(__WIN__)
     38#elif K_OS == K_OS_WINDOWS
    3939# include <windows.h>
    4040# include <string.h>
    4141
    42 #elif defined(__DARWIN__)
     42#elif K_OS == K_OS_DARWIN
    4343# include <unistd.h>
    4444# include <string.h>
     
    5656
    5757
    58 #ifdef __OS2__
     58#if K_OS == K_OS_OS2
    5959/**
    6060 * OS/2 DLL 'main'
     
    8484}
    8585
    86 #elif defined(__WIN__)
     86#elif K_OS == K_OS_WINDOWS
    8787
    8888/**
     
    125125}
    126126
    127 #elif defined(__DARWIN__)
     127#elif K_OS == K_OS_DARWIN
    128128/* later */
    129129
     
    140140void tstWrite(const char *pszMsg)
    141141{
    142 #if defined(__OS2__) || defined(__WIN__)
     142#if K_OS == K_OS_OS2 || K_OS == K_OS_WINDOWS
    143143    /*
    144144     * Line by line.
     
    151151        cbWritten = pszNl - pszMsg;
    152152
    153 #ifdef __OS2__
     153#if K_OS == K_OS_OS2
    154154        if (cbWritten)
    155155            DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten);
    156156        DosWrite((HFILE)2, "\r\n", 2, &cbWritten);
    157 #else /* __WIN32__ */
     157#else
    158158        if (cbWritten)
    159159            WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL);
     
    172172    {
    173173        cbWritten = strlen(pszMsg);
    174 #ifdef __OS2__
     174#if K_OS == K_OS_OS2
    175175        DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten);
    176 #else /* __WIN32__ */
     176#else
    177177        WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL);
    178178#endif
    179179    }
    180180
    181 #elif defined(__DARWIN__)
     181#elif K_OS == K_OS_DARWIN
    182182    write(STDERR_FILENO, pszMsg, strlen(pszMsg));
    183183
  • trunk/kStuff/kLdr/testcase/tstDllMainStub.c

    r2965 r3584  
    3131#include "tst.h"
    3232
    33 #ifdef __OS2__
     33#if K_OS == K_OS_OS2
    3434# define INCL_BASE
    3535# include <os2.h>
    3636
    37 #elif defined(__WIN__)
     37#elif K_OS == K_OS_WINDOWS
    3838# include <windows.h>
    3939
    40 #elif defined(__DARWIN__)
     40#elif K_OS == K_OS_DARWIN
    4141/* later */
    4242
     
    4646
    4747
    48 #ifdef __OS2__
     48#if K_OS == K_OS_OS2
    4949/**
    5050 * OS/2 DLL 'main'
     
    5555}
    5656
    57 #elif defined(__WIN__)
     57#elif K_OS == K_OS_WINDOWS
    5858
    5959/**
     
    6565}
    6666
    67 #elif defined(__DARWIN__)
     67#elif K_OS == K_OS_DARWIN
    6868/* later */
    6969
  • trunk/kStuff/kLdr/testcase/tstExeMainStub.c

    r2878 r3584  
    3131#include "tst.h"
    3232
    33 #ifdef __OS2__
     33#if K_OS == K_OS_OS2
    3434# define INCL_BASE
    3535# include <os2.h>
    3636
    37 #elif defined(__WIN__)
     37#elif K_OS == K_OS_WINDOWS
    3838/* nothing */
    3939
    40 #elif defined(__NT__)
     40#elif K_OS == K_OS_NT
    4141# include <ddk/ntapi.h> /** @todo fix the nt port. */
    4242
     
    4949
    5050
    51 #ifdef __OS2__
     51#if K_OS == K_OS_OS2
    5252/**
    5353 * OS/2 'main'.
     
    6060}
    6161
    62 #elif defined(__WIN__)
     62#elif K_OS == K_OS_WINDOWS
    6363/**
    6464 * Windows'main'
     
    7171}
    7272
    73 #elif defined(__NT__)
     73#elif K_OS == K_OS_NT
    7474/**
    7575 * Windows NT 'main'
Note: See TracChangeset for help on using the changeset viewer.