tstNoCrt-1.cpp revision f84bd15077caab73faad1acd3ac85dbc57a4b67f
/* $Id$ */
/** @file
* IPRT Testcase - Testcase for the No-CRT assembly bits.
*/
/*
* Copyright (C) 2008 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
#ifdef RT_WITHOUT_NOCRT_WRAPPERS
# error "Build error."
#endif
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
#define TSTBUF_SIZE 8192
typedef struct TSTBUF
{
/*******************************************************************************
* Global Variables *
*******************************************************************************/
static unsigned g_cErrors = 0;
{
while (cb--)
}
{
while (cb--)
{
{
g_cErrors++;
/* nandemonai */;
off--;
if (off)
RTPrintf("tstNoCrt-1: %s: %p:%p - %02x instead of %02x\n",
else
RTPrintf("tstNoCrt-1: %s: %p - %02x instead of %02x\n",
}
/* next*/
pb++;
}
}
{
}
{
}
#if 0 /* enable this to test the testcase. */
# define RT_NOCRT(a) a
# ifdef _MSC_VER
# define mempcpy nocrt_mempcpy
# endif
#endif
int main()
{
/*
* Prologue.
*/
RTR3Init();
RTPrintf("tstNoCrt-1: TESTING...\n");
/*
* Sanity.
*/
if (g_cErrors)
{
RTPrintf("tstNoCrt-1: FAILED - fatal sanity error\n");
return 1;
}
do \
{ \
{ \
g_cErrors++; \
} \
} while (0)
do \
{ \
{ \
g_cErrors++; \
} \
} while (0)
void *pv;
#define CHECK_DIFF(op) \
do \
{ \
{ \
g_cErrors++; \
} \
} while (0)
int iDiff;
static char s_szTest1[] = "0123456789abcdef";
static char s_szTest2[] = "0123456789abcdef";
static char s_szTest3[] = "fedcba9876543210";
/*
* memcpy.
*/
RTPrintf("tstNoCrt-1: memcpy\n");
{
{
char sz[32];
}
}
/*
* mempcpy.
*/
RTPrintf("tstNoCrt-1: mempcpy\n");
{
{
char sz[32];
}
}
/*
* memmove.
*/
RTPrintf("tstNoCrt-1: memmove\n");
{
{
/* forward */
char sz[32];
{
}
else
/* backward */
pv = RT_NOCRT(memmove)(&Buf1.abBuf[off2], Buf1.abBuf, TSTBUF_SIZE - off2); CHECK_PV(&Buf1.abBuf[off2]);
{
}
else
/* small unaligned */
}
}
/*
* memset
*/
RTPrintf("tstNoCrt-1: memset\n");
{
/* move start byte by byte. */
char sz[32];
TstBufInit(&Buf1, 0);
/* move end byte by byte. */
TstBufInit(&Buf1, 0);
/* move both start and size byte by byte. */
TstBufInit(&Buf1, 0);
}
/*
* strcpy (quick smoke testing).
*/
RTPrintf("tstNoCrt-1: strcpy\n");
for (unsigned i = 0; i < sizeof(s_szTest1) / 2; i++)
{
pszSrc++;
}
/*
* memchr & strchr.
*/
RTPrintf("tstNoCrt-1: memchr\n");
for (unsigned i = 0; i < sizeof(s_szTest1); i++)
for (unsigned j = 0; j <= i; j++)
{
}
RTPrintf("tstNoCrt-1: strchr\n");
for (unsigned i = 0; i < sizeof(s_szTest1); i++)
for (unsigned j = 0; j <= i; j++)
{
}
/*
*/
RTPrintf("tstNoCrt-1: memcmp\n");
RTPrintf("tstNoCrt-1: strcmp\n");
/*
* Some simple strlen checks.
*/
RTPrintf("tstNoCrt-1: strlen\n");
/*
* Summary.
*/
if (!g_cErrors)
RTPrintf("tstNoCrt-1: SUCCESS\n");
else
return !!g_cErrors;
}