mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-30 19:26:05 +00:00
[CRT_APITEST]
- disable GCC builtins - Add simple tests for strlen, showing that a NULL pointer will cause an access violation, which is broken in our asm implementation svn path=/trunk/; revision=70427
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-fno-builtin")
|
||||
endif()
|
||||
|
||||
include(ntdll_crt_apitest.cmake)
|
||||
include(msvcrt_crt_apitest.cmake)
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ list(APPEND SOURCE_CRTDLL
|
||||
# strcspn.c
|
||||
# strerror.c
|
||||
# strftime.c
|
||||
# strlen.c
|
||||
strlen.c
|
||||
# strncat.c
|
||||
# strncmp.c
|
||||
# strncpy.c
|
||||
|
||||
@@ -1173,7 +1173,7 @@ list(APPEND SOURCE_MSVCRT
|
||||
# strerror.c
|
||||
# strerror_s.c
|
||||
# strftime.c
|
||||
# strlen.c
|
||||
strlen.c
|
||||
# strncat.c
|
||||
# strncat_s
|
||||
# strncmp.c
|
||||
|
||||
@@ -88,7 +88,7 @@ list(APPEND SOURCE_NTDLL
|
||||
# strcmp.c
|
||||
strcpy.c
|
||||
# strcspn.c
|
||||
# strlen.c
|
||||
strlen.c
|
||||
# strncat.c
|
||||
# strncmp.c
|
||||
# strncpy.c
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||
* PURPOSE: Test for strlen
|
||||
* PROGRAMMER: Timo Kreuzer <[email protected]>
|
||||
*/
|
||||
|
||||
#include <apitest.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <pseh/pseh2.h>
|
||||
#include <ntstatus.h>
|
||||
typedef _Return_type_success_(return >= 0) long NTSTATUS, *PNTSTATUS;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wnonnull"
|
||||
|
||||
size_t
|
||||
GCC_builtin_strlen(const char *str)
|
||||
{
|
||||
return __builtin_strlen(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef size_t (*PFN_STRLEN)(const char *);
|
||||
|
||||
void
|
||||
Test_strlen(PFN_STRLEN pstrlen)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
/* basic parameter tests */
|
||||
StartSeh()
|
||||
len = pstrlen(NULL);
|
||||
EndSeh(STATUS_ACCESS_VIOLATION);
|
||||
(void)len;
|
||||
|
||||
ok_int((int)pstrlen("test"), 4);
|
||||
}
|
||||
|
||||
START_TEST(strlen)
|
||||
{
|
||||
Test_strlen(strlen);
|
||||
#ifdef __GNUC__
|
||||
Test_strlen(GCC_builtin_strlen);
|
||||
#endif // __GNUC__
|
||||
}
|
||||
@@ -15,6 +15,7 @@ extern void func__vsnwprintf(void);
|
||||
extern void func_mbstowcs(void);
|
||||
extern void func_sprintf(void);
|
||||
extern void func_strcpy(void);
|
||||
extern void func_strlen(void);
|
||||
extern void func_wcstombs(void);
|
||||
|
||||
extern void func_static_construct(void);
|
||||
@@ -27,6 +28,7 @@ const struct test winetest_testlist[] =
|
||||
{ "mbstowcs", func_mbstowcs },
|
||||
{ "sprintf", func_sprintf },
|
||||
{ "strcpy", func_strcpy },
|
||||
{ "strlen", func_strlen },
|
||||
{ "wcstombs", func_wcstombs },
|
||||
#if defined(TEST_CRTDLL) || defined(TEST_MSVCRT) || defined(TEST_STATIC_CRT)
|
||||
// ...
|
||||
|
||||
Reference in New Issue
Block a user