Author: tkreuzer
Date: Sat Dec 26 19:20:54 2015
New Revision: 70427
URL:
http://svn.reactos.org/svn/reactos?rev=70427&view=rev
Log:
[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
Added:
trunk/rostests/apitests/crt/strlen.c (with props)
Modified:
trunk/rostests/apitests/crt/CMakeLists.txt
trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake
trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake
trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake
trunk/rostests/apitests/crt/testlist.c
Modified: trunk/rostests/apitests/crt/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/CMakeLists.t…
==============================================================================
--- trunk/rostests/apitests/crt/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/CMakeLists.txt [iso-8859-1] Sat Dec 26 19:20:54 2015
@@ -1,3 +1,7 @@
+
+if(GCC)
+ add_compile_flags("-fno-builtin")
+endif()
include(ntdll_crt_apitest.cmake)
include(msvcrt_crt_apitest.cmake)
Modified: trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/crtdll_crt_a…
==============================================================================
--- trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/crtdll_crt_apitest.cmake [iso-8859-1] Sat Dec 26 19:20:54
2015
@@ -466,7 +466,7 @@
# strcspn.c
# strerror.c
# strftime.c
-# strlen.c
+ strlen.c
# strncat.c
# strncmp.c
# strncpy.c
Modified: trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/msvcrt_crt_a…
==============================================================================
--- trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] Sat Dec 26 19:20:54
2015
@@ -1173,7 +1173,7 @@
# strerror.c
# strerror_s.c
# strftime.c
-# strlen.c
+ strlen.c
# strncat.c
# strncat_s
# strncmp.c
Modified: trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/ntdll_crt_ap…
==============================================================================
--- trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/ntdll_crt_apitest.cmake [iso-8859-1] Sat Dec 26 19:20:54
2015
@@ -88,7 +88,7 @@
# strcmp.c
strcpy.c
# strcspn.c
-# strlen.c
+ strlen.c
# strncat.c
# strncmp.c
# strncpy.c
Added: trunk/rostests/apitests/crt/strlen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/strlen.c?rev…
==============================================================================
--- trunk/rostests/apitests/crt/strlen.c (added)
+++ trunk/rostests/apitests/crt/strlen.c [iso-8859-1] Sat Dec 26 19:20:54 2015
@@ -0,0 +1,48 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for strlen
+ * PROGRAMMER: Timo Kreuzer <timo.kreuzer(a)reactos.org>
+ */
+
+#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__
+}
Propchange: trunk/rostests/apitests/crt/strlen.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/crt/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/testlist.c?r…
==============================================================================
--- trunk/rostests/apitests/crt/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/testlist.c [iso-8859-1] Sat Dec 26 19:20:54 2015
@@ -15,6 +15,7 @@
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 @@
{ "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)
// ...