Andrew Nguyen : msvcrt/tests: Add tests for the __p__(w)environ accessors.

Alexandre Julliard julliard at winehq.org
Thu Oct 7 11:24:25 CDT 2010


Module: wine
Branch: master
Commit: 797d6cb4e24b90f93cc8efaa854b7758a36ea15e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=797d6cb4e24b90f93cc8efaa854b7758a36ea15e

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Wed Oct  6 21:58:39 2010 -0500

msvcrt/tests: Add tests for the __p__(w)environ accessors.

---

 dlls/msvcrt/tests/environ.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/dlls/msvcrt/tests/environ.c b/dlls/msvcrt/tests/environ.c
index 3169503..2e3e7f8 100644
--- a/dlls/msvcrt/tests/environ.c
+++ b/dlls/msvcrt/tests/environ.c
@@ -45,6 +45,9 @@ static const char *a_very_long_env_string =
 void __cdecl __getmainargs(int *, char ***, char ***, int, int *);
 void __cdecl __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
 
+static char ***(__cdecl *p__p__environ)(void);
+static WCHAR ***(__cdecl *p__p__wenviron)(void);
+
 static char ***p_environ;
 static WCHAR ***p_wenviron;
 
@@ -52,6 +55,8 @@ static void init(void)
 {
     HMODULE hmod = GetModuleHandleA("msvcrt.dll");
 
+    p__p__environ = (void *)GetProcAddress(hmod, "__p__environ");
+    p__p__wenviron = (void *)GetProcAddress(hmod, "__p__wenviron");
     p_environ = (void *)GetProcAddress(hmod, "_environ");
     p_wenviron = (void *)GetProcAddress(hmod, "_wenviron");
 }
@@ -81,6 +86,15 @@ static void test__environ(void)
         return;
     }
 
+    /* Examine the returned pointer from __p__environ(), if available. */
+    if (p__p__environ)
+    {
+        ok( *p__p__environ() == *p_environ,
+            "Expected _environ pointers to be identical\n" );
+    }
+    else
+        skip( "__p__environ() is not available\n" );
+
     /* Note that msvcrt from Windows versions older than Vista
      * expects the mode pointer parameter to be valid.*/
     __getmainargs(&argc, &argv, &envp, 0, &mode);
@@ -125,6 +139,15 @@ static void test__wenviron(void)
         return;
     }
 
+    /* Examine the returned pointer from __p__wenviron(), if available. */
+    if (p__p__wenviron)
+    {
+        ok( *p__p__wenviron() == NULL,
+            "Expected _wenviron pointers to be NULL\n" );
+    }
+    else
+        skip( "__p__wenviron() is not available\n" );
+
     /* __getmainargs doesn't initialize _wenviron. */
     __getmainargs(&argc, &argv, &envp, 0, &mode);
 
@@ -153,6 +176,14 @@ static void test__wenviron(void)
         return;
     }
 
+    /* Examine the returned pointer from __p__wenviron(),
+     * if available, after _wenviron is initialized. */
+    if (p__p__wenviron)
+    {
+        ok( *p__p__wenviron() == *p_wenviron,
+            "Expected _wenviron pointers to be identical\n" );
+    }
+
     for (i = 0; ; i++)
     {
         if ((*p_wenviron)[i])




More information about the wine-cvs mailing list