VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTDarwinMachKernel.cpp@ 39872

Last change on this file since 39872 was 37573, checked in by vboxsync, 14 years ago

iprt: More kernel symbol resolving on darwin.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/* $Id: tstRTDarwinMachKernel.cpp 37573 2011-06-21 11:40:11Z vboxsync $ */
2/** @file
3 * IPRT Testcase - mach_kernel symbol resolving hack.
4 */
5
6/*
7 * Copyright (C) 2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include <iprt/darwin/machkernel.h>
32#include <iprt/err.h>
33#include <iprt/string.h>
34#include <iprt/test.h>
35
36
37
38static void dotest(const char *pszMachKernel)
39{
40 RTR0MACHKERNEL hKernel;
41 RTTESTI_CHECK_RC_RETV(RTR0MachKernelOpen(pszMachKernel, &hKernel), VINF_SUCCESS);
42 static const char * const s_apszSyms[] =
43 {
44 "ast_pending",
45 "cpu_interrupt",
46 "dtrace_register",
47 "dtrace_suspend",
48 };
49 for (unsigned i = 0; i < RT_ELEMENTS(s_apszSyms); i++)
50 {
51 void *pvValue = NULL;
52 int rc = RTR0MachKernelGetSymbol(hKernel, s_apszSyms[i], &pvValue);
53 RTTestIPrintf(RTTESTLVL_ALWAYS, "%Rrc %p %s\n", rc, pvValue, s_apszSyms[i]);
54 RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
55 if (RT_SUCCESS(rc))
56 RTTESTI_CHECK_RC(RTR0MachKernelGetSymbol(hKernel, s_apszSyms[i], NULL), VINF_SUCCESS);
57 }
58
59 RTTESTI_CHECK_RC(RTR0MachKernelGetSymbol(hKernel, "no_such_symbol_name_really", NULL), VERR_SYMBOL_NOT_FOUND);
60 RTTESTI_CHECK_RC(RTR0MachKernelClose(hKernel), VINF_SUCCESS);
61 RTTESTI_CHECK_RC(RTR0MachKernelClose(NIL_RTR0MACHKERNEL), VINF_SUCCESS);
62}
63
64
65int main(int argc, char **argv)
66{
67 RTTEST hTest;
68 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTMachKernel", &hTest);
69 if (rcExit != RTEXITCODE_SUCCESS)
70 return rcExit;
71 RTTestBanner(hTest);
72
73 dotest("/mach_kernel");
74
75 return RTTestSummaryAndDestroy(hTest);
76}
77
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette