Changeset 2967 for trunk/kLdr/testcase


Ignore:
Timestamp:
Feb 13, 2007, 11:28:46 PM (19 years ago)
Author:
bird
Message:

More testcase fun.

Location:
trunk/kLdr/testcase
Files:
3 added
3 edited
3 copied

Legend:

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

    r2965 r2967  
    121121  TEMPLATE_TSTBARE_DEFS = __DARWIN__
    122122  TEMPLATE_TSTBARE_LIBS =
    123   TEMPLATE_TSTBARE_CFLAGS += -static
     123  TEMPLATE_TSTBARE_CFLAGS += -static
    124124  TEMPLATE_TSTBARE_LDFLAGS += -nostdlib -r
    125125 else
     
    270270#
    271271PROGRAMS += tst-3-driver
     272
     273
     274
    272275DLLS += tst-3
     276
     277
     278
    273279
    274280tst-3_TEMPLATE = TSTBAREDLL
    275 tst-3_SOURCES  = tst-3.c tstDllMainStub.c
     281tst-3_SOURCES  = tst-3.c tstDllMainStub.c
    276282tst-3_SOURCES.os2= tstDllMainStub-os2.asm
     283
     284
     285
     286
     287
     288
    277289
    278290tst-3-driver_TEMPLATE = TSTPROG
  • trunk/kLdr/testcase/tst-3-driver.c

    r2965 r2967  
    7272
    7373
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
    7488static int GetImport(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_t cchSymbol,
    7589                     const char *pszVersion, PKLDRADDR puValue, uint32_t *pfKind, void *pvUser)
    7690{
    77     /** todo */
    78     return -1;
     91    if (*pfKind != KLDRSYMKIND_REQ_FLAT)
     92        return -1;
     93
     94    if (    !strncmp(pchSymbol, "Tst3Ext", strlen("Tst3Ext"))
     95        ||  !strncmp(pchSymbol, "_Tst3Ext", strlen("_Tst3Ext")))
     96    {
     97        *puValue = (uintptr_t)&Tst3Ext;
     98        *pfKind = KLDRSYMKIND_CODE | (sizeof(pfKind) == 4 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT);
     99        return 0;
     100    }
     101
     102    return -2;
    79103}
    80104
     
    100124    /* get bits. */
    101125    cbImage = kLdrModSize(pMod);
    102     pvBits = malloc((size_t)cbImage);
     126    pvBits = malloc((size_t)cbImage);
    103127    if (pvBits)
    104128    {
    105         KLDRADDR BaseAddress = (uintptr_t)pvBits;
    106         rc = kLdrModGetBits(pMod, pvBits, BaseAddress, GetImport, NULL);
     129        void *pvBits2 = (void *)( ((uintptr_t)pvBits + 0xfff) & ~(uintptr_t)0xfff );
     130
     131        KLDRADDR BaseAddress = (uintptr_t)pvBits2;
     132        rc = kLdrModGetBits(pMod, pvBits2, BaseAddress, GetImport, NULL);
    107133        if (!rc)
    108134        {
    109             const char *pszSym = MY_NAME("Tst3");
    110135            KLDRADDR EntryPoint;
    111136
    112137            /* call into it */
    113             rc = kLdrModQuerySymbol(pMod, pvBits, BaseAddress, NIL_KLDRMOD_SYM_ORDINAL, pszSym, strlen(pszSym), NULL, NULL, NULL,
     138            rc = kLdrModQuerySymbol(pMod, pvBits), NULL, NULL, NULL,
    114139                                    &EntryPoint, NULL);
     140
     141
     142
    115143            if (!rc)
    116144            {
     
    120148                {
    121149                    /* relocate twice and try again. */
    122                     rc = kLdrModRelocateBits(pMod, pvBits, BaseAddress + 0x22000, BaseAddress, GetImport, NULL);
     150                    rc = kLdrModRelocateBits(pMod, pvBits, BaseAddress + 0x22000, BaseAddress, GetImport, NULL);
    123151                    if (!rc)
    124152                    {
    125                         rc = kLdrModRelocateBits(pMod, pvBits, BaseAddress, BaseAddress + 0x22000, GetImport, NULL);
     153                        rc = kLdrModRelocateBits(pMod, pvBits, BaseAddress, BaseAddress + 0x22000, GetImport, NULL);
    126154                        if (!rc)
    127155                        {
     
    178206     */
    179207    if (!g_cErrors)
    180         printf("tst-0-driver: SUCCESS\n");
     208        printf("tst--driver: SUCCESS\n");
    181209    else
    182         printf("tst-0-driver: FAILURE - %d errors\n", g_cErrors);
     210        printf("tst--driver: FAILURE - %d errors\n", g_cErrors);
    183211    return !!g_cErrors;
    184212}
  • trunk/kLdr/testcase/tst-3-ext.c

    r2965 r2967  
    22/** @file
    33 *
    4  * kLdr - Dynamic Loader testcase no. 3, Driver.
     4 * kLdr - Dynamic Loader testcase no. 3, .
    55 *
    66 * Copyright (c) 2006 knut st. osmundsen <[email protected]>
     
    2828#include "tst.h"
    2929
    30 
    31 int g_i1 = 1;
    32 int g_i2 = 2;
    33 int *g_pi1 = &g_i1;
    34 
    35 int Tst3Sub(int);
    36 int (*g_pfnTst3Sub)(int) = &Tst3Sub;
    37 
    38 char g_achBss[256];
    39 
    40 
    41 MY_EXPORT(int) Tst3(int iFortyTwo)
    42 {
    43     int rc;
    44 
    45     if (iFortyTwo != 42)
    46         return 0;
    47     if (g_i1 != 1)
    48         return 1;
    49     if (g_i2 != 2)
    50         return 2;
    51     if (g_pi1 != &g_i1)
    52         return 3;
    53     if (g_pfnTst3Sub != &Tst3Sub)
    54         return 4;
    55     rc = Tst3Sub(iFortyTwo);
    56     if (rc != g_pfnTst3Sub(iFortyTwo))
    57         return 5;
    58     for (rc = 0; rc < sizeof(g_achBss); rc++)
    59         if (g_achBss[rc])
    60             return 6;
    61     if (g_achBss[0] || g_achBss[1] || g_achBss[255])
    62         return 7;
    63 
    64     return 42;
    65 }
    66 
     30extern int g_i1;
    6731
    6832int Tst3Sub(int iFortyTwo)
    6933{
    70     return iFortyTwo * 11;
     34    return iFortyTwo * 11;
    7135}
    7236
  • trunk/kLdr/testcase/tst-3-imp-os2.def

    r2965 r2967  
    1 /* $Id$ */
    2 /** @file
    3  *
    4  * kLdr - Dynamic Loader testcase no. 3, Driver.
    5  *
    6  * Copyright (c) 2006 knut st. osmundsen <[email protected]>
    7  *
    8  *
    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
    24  *
    25  */
     1; $Id$
     2 @file
     3;
     4.
     5;
     6 Copyright (c) 2006 knut st. osmundsen <[email protected]>
     7;
     8;
     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
     24;
     25;
    2626
     27
     28
     29
    2730
    28 #include "tst.h"
    29 
    30 
    31 int g_i1 = 1;
    32 int g_i2 = 2;
    33 int *g_pi1 = &g_i1;
    34 
    35 int Tst3Sub(int);
    36 int (*g_pfnTst3Sub)(int) = &Tst3Sub;
    37 
    38 char g_achBss[256];
    39 
    40 
    41 MY_EXPORT(int) Tst3(int iFortyTwo)
    42 {
    43     int rc;
    44 
    45     if (iFortyTwo != 42)
    46         return 0;
    47     if (g_i1 != 1)
    48         return 1;
    49     if (g_i2 != 2)
    50         return 2;
    51     if (g_pi1 != &g_i1)
    52         return 3;
    53     if (g_pfnTst3Sub != &Tst3Sub)
    54         return 4;
    55     rc = Tst3Sub(iFortyTwo);
    56     if (rc != g_pfnTst3Sub(iFortyTwo))
    57         return 5;
    58     for (rc = 0; rc < sizeof(g_achBss); rc++)
    59         if (g_achBss[rc])
    60             return 6;
    61     if (g_achBss[0] || g_achBss[1] || g_achBss[255])
    62         return 7;
    63 
    64     return 42;
    65 }
    66 
    67 
    68 int Tst3Sub(int iFortyTwo)
    69 {
    70     return iFortyTwo * 11;
    71 }
    72 
  • trunk/kLdr/testcase/tst-3-imp-win.def

    r2965 r2967  
    1 /* $Id$ */
    2 /** @file
    3  *
    4  * kLdr - Dynamic Loader testcase no. 3, Driver.
    5  *
    6  * Copyright (c) 2006 knut st. osmundsen <[email protected]>
    7  *
    8  *
    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
    24  *
    25  */
     1; $Id$
     2 @file
     3;
     4.
     5;
     6 Copyright (c) 2006 knut st. osmundsen <[email protected]>
     7;
     8;
     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
     24;
     25;
    2626
     27
     28
     29
    2730
    28 #include "tst.h"
    29 
    30 
    31 int g_i1 = 1;
    32 int g_i2 = 2;
    33 int *g_pi1 = &g_i1;
    34 
    35 int Tst3Sub(int);
    36 int (*g_pfnTst3Sub)(int) = &Tst3Sub;
    37 
    38 char g_achBss[256];
    39 
    40 
    41 MY_EXPORT(int) Tst3(int iFortyTwo)
    42 {
    43     int rc;
    44 
    45     if (iFortyTwo != 42)
    46         return 0;
    47     if (g_i1 != 1)
    48         return 1;
    49     if (g_i2 != 2)
    50         return 2;
    51     if (g_pi1 != &g_i1)
    52         return 3;
    53     if (g_pfnTst3Sub != &Tst3Sub)
    54         return 4;
    55     rc = Tst3Sub(iFortyTwo);
    56     if (rc != g_pfnTst3Sub(iFortyTwo))
    57         return 5;
    58     for (rc = 0; rc < sizeof(g_achBss); rc++)
    59         if (g_achBss[rc])
    60             return 6;
    61     if (g_achBss[0] || g_achBss[1] || g_achBss[255])
    62         return 7;
    63 
    64     return 42;
    65 }
    66 
    67 
    68 int Tst3Sub(int iFortyTwo)
    69 {
    70     return iFortyTwo * 11;
    71 }
    72 
  • trunk/kLdr/testcase/tst-3.c

    r2965 r2967  
    3333int *g_pi1 = &g_i1;
    3434
    35 int Tst3Sub(int);
     35int Tst3Sub(int);
    3636int (*g_pfnTst3Sub)(int) = &Tst3Sub;
     37
     38
     39
    3740
    3841char g_achBss[256];
     
    5659    if (rc != g_pfnTst3Sub(iFortyTwo))
    5760        return 5;
     61
     62
     63
     64
     65
     66
    5867    for (rc = 0; rc < sizeof(g_achBss); rc++)
    5968        if (g_achBss[rc])
    60             return 6;
     69            return ;
    6170    if (g_achBss[0] || g_achBss[1] || g_achBss[255])
    62         return 7;
     71        return ;
    6372
    6473    return 42;
    6574}
    6675
    67 
    68 int Tst3Sub(int iFortyTwo)
    69 {
    70     return iFortyTwo * 11;
    71 }
    72 
Note: See TracChangeset for help on using the changeset viewer.