Changeset 2863
- Timestamp:
- Nov 10, 2006, 5:05:39 AM (19 years ago)
- Location:
- trunk/kLdr/testcase
- Files:
-
- 1 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/testcase/Makefile.kmk
r2862 r2863 33 33 34 34 # 35 # Template fortestcases.35 # Templates for the testcases. 36 36 # 37 37 TEMPLATE_TST = Testcase template … … 82 82 83 83 84 TEMPLATE_TSTBARE = Bare bone testcase template 85 ifneq ($(filter win nt win32 win64,$(BUILD_TARGET)),) 86 TEMPLATE_TSTBARE_TOOL = VCC70 87 TEMPLATE_TSTBARE_CFLAGS = -W3 -Zi -Zl 88 TEMPLATE_TSTBARE_CFLAGS.release = -O2 89 TEMPLATE_TSTBARE_CXXFLAGS = -W3 -Zi -Zl 90 TEMPLATE_TSTBARE_CXXFLAGS.release = -O2 91 TEMPLATE_TSTBARE_ASFLAGS = -f win 92 TEMPLATE_TSTBARE_DEFS = __WIN__ 93 TEMPLATE_TSTBARE_SDKS = WIN32SDK 94 95 else 96 ifneq ($(filter os2,$(BUILD_TARGET)),) 97 TEMPLATE_TSTBARE_TOOL = GCC3OMF 98 TEMPLATE_TSTBARE_ASFLAGS = -f obj 99 TEMPLATE_TSTBARE_LIBS = os2 gcc end 100 else 101 TEMPLATE_TSTBARE_TOOL = GCC3 102 TEMPLATE_TSTBARE_ASFLAGS = -f elf 103 TEMPLATE_TSTBARE_LIBS = gcc 104 endif 105 TEMPLATE_TSTBARE_CFLAGS = -Wall -pedantic -g 106 TEMPLATE_TSTBARE_CFLAGS.release = -O2 107 TEMPLATE_TSTBARE_LDFLAGS = -nostdlib -lgcc 108 endif 109 TEMPLATE_TSTBARE_INCS = . 110 111 TEMPLATE_TSTBAREPROG = Bare bone testcase program template 112 TEMPLATE_TSTBAREPROG_EXTENDS = TSTBARE 113 ifneq ($(filter win nt win32 win64,$(BUILD_TARGET)),) 114 TEMPLATE_TSTBAREPROG_LDFLAGS += -Entry:WinMain -FIXED:NO 115 else 116 endif 117 118 119 TEMPLATE_TSTBAREDLL = Bare bone testcase dll template 120 TEMPLATE_TSTBAREDLL_EXTENDS = TSTBARE 121 ifneq ($(filter win nt win32 win64,$(BUILD_TARGET)),) 122 TEMPLATE_TSTBAREDLL_LDFLAGS += -Entry:DllMain 123 else 124 endif 125 126 127 128 129 # 130 # tst-0: four dlls, three of which depends on the 4th and no external dependencies. 131 # The purpose of this testcase is to debug the dynamic loader without 132 # messing with the native loader at all. 133 # 134 PROGRAMS += tst-0 135 DLLS += tst-0-a tst-0-b tst-0-c tst-0-d 136 137 tst-0-a_TEMPLATE = TSTBAREDLL 138 tst-0-a_SOURCES = tst-0-a.c tstDllMainStub.c 139 140 tst-0-b_TEMPLATE = TSTBAREDLL 141 tst-0-b_SOURCES = tst-0-b.c tstDllMainStub.c 142 143 tst-0-c_TEMPLATE = TSTBAREDLL 144 tst-0-c_SOURCES = tst-0-c.c tstDllMainStub.c 145 146 tst-0-d_TEMPLATE = TSTBAREDLL 147 tst-0-d_SOURCES = tst-0-d.c tstDllMainStub.c 148 149 tst-0_TEMPLATE = TSTPROG 150 tst-0_SOURCES = tst-0.c 151 152 ifeq ($(filter-out nt win win32 win64,$(BUILD_TARGET)),) 153 tst-0-a_LIBS = $(PATH_TARGET)/tst-0-d/tst-0-d.lib 154 tst-0-b_LIBS = $(PATH_TARGET)/tst-0-d/tst-0-d.lib 155 tst-0-c_LIBS = $(PATH_TARGET)/tst-0-d/tst-0-d.lib 156 tst-0_LIBS = $(TARGET_tst-0-a:.dll=.lib) $(TARGET_tst-0-b:.dll=.lib) $(TARGET_tst-0-c:.dll=.lib) 157 else 158 tst-0-a_LIBS = $(TARGET_tst-0-a:-a=-d) 159 tst-0-b_LIBS = $(TARGET_tst-0-b:-b=-d) 160 tst-0-c_LIBS = $(TARGET_tst-0-c:-c=-d) 161 tst-0_LIBS = $(TARGET_tst-0-a) $(TARGET_tst-0-b) $(TARGET_tst-0-c) 162 endif 163 164 84 165 # 85 166 # tst-1: four dlls, three of which depends on the 4th and the testcase depends on those three again. -
trunk/kLdr/testcase/tst-0-a.c
r2841 r2863 6 6 MY_EXPORT(int) FuncA(void) 7 7 { 8 return FuncD() ;8 return FuncD() | (g_pszName[0] == 'a' ? 0x42 : 0x0001); 9 9 } 10 10 -
trunk/kLdr/testcase/tst-0-b.c
r2841 r2863 6 6 MY_EXPORT(int) FuncB(void) 7 7 { 8 return FuncD() ;8 return FuncD() | (g_pszName[0] == 'b' ? 0x4200 : 0x0010); 9 9 } 10 10 -
trunk/kLdr/testcase/tst-0-c.c
r2841 r2863 6 6 MY_EXPORT(int) FuncC(void) 7 7 { 8 return FuncD() ;8 return FuncD() | (g_pszName[0] == 'c' ? 0x420000 : 0x0100); 9 9 } 10 10 -
trunk/kLdr/testcase/tst-0-d.c
r2841 r2863 4 4 MY_EXPORT(int) FuncD(void) 5 5 { 6 return 0;6 return g_pszName[0] == 'd' ? 0x42000000 : 0x1000; 7 7 } 8 8 -
trunk/kLdr/testcase/tst-0.c
r2841 r2863 8 8 int main() 9 9 { 10 unsigned long ul; 10 11 printf("graph:\n" 11 " tst- 1-> a -> d\n"12 " tst-0 -> a -> d\n" 12 13 " b -> d\n" 13 14 " c -> d\n"); 14 return FuncA() + FuncB() + FuncC(); 15 ul = FuncA() | FuncB() | FuncC(); 16 if (ul == 0x42424242) 17 printf("tst-0: success, ul=%#lx\n", ul); 18 else 19 printf("tst-0: failure, ul=%#lx\n", ul); 20 return ul == 0x42424242 ? 0 : 1; 15 21 } -
trunk/kLdr/testcase/tstDllMainStub.c
r2841 r2863 2 2 /** @file 3 3 * 4 * kLdr testcase .4 * kLdr testcase - DLL Stub. 5 5 * 6 6 * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net> … … 34 34 # define INCL_BASE 35 35 # include <os2.h> 36 # include <string.h>37 36 38 37 #elif defined(__WIN__) 39 38 # include <windows.h> 40 # include <string.h>41 39 42 40 #else 43 41 # error "port me" 44 42 #endif 45 46 /*******************************************************************************47 * Internal Functions *48 *******************************************************************************/49 static void tstWrite(const char *psz);50 51 43 52 44 … … 57 49 ULONG _System _DLL_InitTerm(HMODULE hmod, ULONG fFlag) 58 50 { 59 switch (fFlags) 60 { 61 case 0: 62 tstWrite("init: "); 63 tstWrite(g_pszName); 64 tstWrite("\n"); 65 return TRUE; 66 67 case 1: 68 tstWrite("term: "); 69 tstWrite(g_pszName); 70 tstWrite("\n"); 71 return TRUE; 72 73 default: 74 tstWrite("!invalid!: "); 75 tstWrite(g_pszName); 76 tstWrite("\n"); 77 return FALSE; 78 } 51 return TRUE; 79 52 } 80 53 … … 82 55 83 56 /** 84 * OS/2DLL 'main'57 * Window DLL 'main' 85 58 */ 86 59 BOOL __stdcall DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved) 87 60 { 88 switch (dwReason) 89 { 90 case DLL_PROCESS_ATTACH: 91 tstWrite("init: "); 92 tstWrite(g_pszName); 93 tstWrite("\n"); 94 return TRUE; 95 96 case DLL_PROCESS_DETACH: 97 tstWrite("term: "); 98 tstWrite(g_pszName); 99 tstWrite("\n"); 100 return TRUE; 101 102 case DLL_THREAD_ATTACH: 103 tstWrite("thread init: "); 104 tstWrite(g_pszName); 105 tstWrite("\n"); 106 return TRUE; 107 108 case DLL_THREAD_DETACH: 109 tstWrite("thread term: "); 110 tstWrite(g_pszName); 111 tstWrite("\n"); 112 return TRUE; 113 114 default: 115 tstWrite("!invalid!: "); 116 tstWrite(g_pszName); 117 tstWrite("\n"); 118 return FALSE; 119 } 61 return TRUE; 120 62 } 121 63 … … 124 66 #endif 125 67 126 127 /**128 * Writes a string with unix lineendings.129 *130 * @param pszMsg The string.131 */132 static void tstWrite(const char *pszMsg)133 {134 #if defined(__OS2__) || defined(__WIN__)135 /*136 * Line by line.137 */138 ULONG cbWritten;139 const char *pszNl = strchr(pszMsg, '\n');140 141 while (pszNl)142 {143 cbWritten = pszNl - pszMsg;144 145 #ifdef __OS2__146 if (cbWritten)147 DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten);148 DosWrite((HFILE)2, "\r\n", 2, &cbWritten);149 #else /* __WIN32__ */150 if (cbWritten)151 WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL);152 WriteFile((HANDLE)STD_ERROR_HANDLE, "\r\n", 2, &cbWritten, NULL);153 #endif154 155 /* next */156 pszMsg = pszNl + 1;157 pszNl = strchr(pszMsg, '\n');158 }159 160 /*161 * Remaining incomplete line.162 */163 if (*pszMsg)164 {165 cbWritten = strlen(pszMsg);166 #ifdef __OS2__167 DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten);168 #else /* __WIN32__ */169 WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL);170 #endif171 }172 173 #else174 # error "port me"175 #endif176 }177 178
Note:
See TracChangeset
for help on using the changeset viewer.