From ffb04579826c5024387ff01e7ef36b96ad092d66 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 29 Apr 2008 18:09:24 -0700 Subject: [PATCH] userenv: Add initial tests for CreateEnvironmentBlock. --- .gitignore | 5 +++ Makefile.in | 2 ++ configure | 3 ++ configure.ac | 1 + dlls/Makefile.in | 5 +++ dlls/userenv/Makefile.in | 1 + dlls/userenv/tests/Makefile.in | 13 ++++++++ dlls/userenv/tests/userenv.c | 59 ++++++++++++++++++++++++++++++++++ programs/winetest/Makefile.in | 3 ++ programs/winetest/winetest.rc | 1 + 10 files changed, 93 insertions(+) create mode 100644 dlls/userenv/tests/Makefile.in create mode 100644 dlls/userenv/tests/userenv.c diff --git a/.gitignore b/.gitignore index 7aeef028d01..b74bd9521cd 100644 --- a/.gitignore +++ b/.gitignore @@ -419,6 +419,10 @@ dlls/user32/libuser32.def dlls/user32/tests/*.ok dlls/user32/tests/testlist.c dlls/user32/tests/user32_crosstest.exe +dlls/userenv/libuserenv.def +dlls/userenv/tests/*.ok +dlls/userenv/tests/testlist.c +dlls/userenv/tests/userenv_crosstest.exe dlls/usp10/libusp10.def dlls/usp10/tests/*.ok dlls/usp10/tests/testlist.c @@ -681,6 +685,7 @@ programs/winetest/snmpapi_test.exe programs/winetest/spoolss_test.exe programs/winetest/urlmon_test.exe programs/winetest/user32_test.exe +programs/winetest/userenv_test.exe programs/winetest/usp10_test.exe programs/winetest/uxtheme_test.exe programs/winetest/version_test.exe diff --git a/Makefile.in b/Makefile.in index c91c86d1d06..aac678dbafc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -459,6 +459,7 @@ ALL_MAKEFILES = \ dlls/user32/Makefile \ dlls/user32/tests/Makefile \ dlls/userenv/Makefile \ + dlls/userenv/tests/Makefile \ dlls/usp10/Makefile \ dlls/usp10/tests/Makefile \ dlls/uuid/Makefile \ @@ -884,6 +885,7 @@ dlls/urlmon/tests/Makefile: dlls/urlmon/tests/Makefile.in dlls/Maketest.rules dlls/user32/Makefile: dlls/user32/Makefile.in dlls/Makedll.rules dlls/user32/tests/Makefile: dlls/user32/tests/Makefile.in dlls/Maketest.rules dlls/userenv/Makefile: dlls/userenv/Makefile.in dlls/Makedll.rules +dlls/userenv/tests/Makefile: dlls/userenv/tests/Makefile.in dlls/Maketest.rules dlls/usp10/Makefile: dlls/usp10/Makefile.in dlls/Makedll.rules dlls/usp10/tests/Makefile: dlls/usp10/tests/Makefile.in dlls/Maketest.rules dlls/uuid/Makefile: dlls/uuid/Makefile.in dlls/Makeimplib.rules diff --git a/configure b/configure index 45c98c6b8b8..87a5a173e82 100755 --- a/configure +++ b/configure @@ -22077,6 +22077,8 @@ ac_config_files="$ac_config_files dlls/user32/tests/Makefile" ac_config_files="$ac_config_files dlls/userenv/Makefile" +ac_config_files="$ac_config_files dlls/userenv/tests/Makefile" + ac_config_files="$ac_config_files dlls/usp10/Makefile" ac_config_files="$ac_config_files dlls/usp10/tests/Makefile" @@ -23170,6 +23172,7 @@ do "dlls/user32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/user32/Makefile" ;; "dlls/user32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/user32/tests/Makefile" ;; "dlls/userenv/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/userenv/Makefile" ;; + "dlls/userenv/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/userenv/tests/Makefile" ;; "dlls/usp10/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/usp10/Makefile" ;; "dlls/usp10/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/usp10/tests/Makefile" ;; "dlls/uuid/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/uuid/Makefile" ;; diff --git a/configure.ac b/configure.ac index da31303b985..5c02fb43af5 100644 --- a/configure.ac +++ b/configure.ac @@ -1977,6 +1977,7 @@ AC_CONFIG_FILES([dlls/urlmon/tests/Makefile]) AC_CONFIG_FILES([dlls/user32/Makefile]) AC_CONFIG_FILES([dlls/user32/tests/Makefile]) AC_CONFIG_FILES([dlls/userenv/Makefile]) +AC_CONFIG_FILES([dlls/userenv/tests/Makefile]) AC_CONFIG_FILES([dlls/usp10/Makefile]) AC_CONFIG_FILES([dlls/usp10/tests/Makefile]) AC_CONFIG_FILES([dlls/uuid/Makefile]) diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 9b979acefde..d3bb2b7a524 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -355,6 +355,7 @@ TESTSUBDIRS = \ spoolss/tests \ urlmon/tests \ user32/tests \ + userenv/tests \ usp10/tests \ uxtheme/tests \ version/tests \ @@ -650,6 +651,7 @@ IMPORT_LIBS = \ url/liburl.$(IMPLIBEXT) \ urlmon/liburlmon.$(IMPLIBEXT) \ user32/libuser32.$(IMPLIBEXT) \ + userenv/libuserenv.$(IMPLIBEXT) \ usp10/libusp10.$(IMPLIBEXT) \ uxtheme/libuxtheme.$(IMPLIBEXT) \ vdmdbg/libvdmdbg.$(IMPLIBEXT) \ @@ -1013,6 +1015,9 @@ urlmon/liburlmon.$(IMPLIBEXT): urlmon/urlmon.spec $(WINEBUILD) user32/libuser32.$(IMPLIBEXT): user32/user32.spec $(WINEBUILD) @cd user32 && $(MAKE) libuser32.$(IMPLIBEXT) +userenv/libuserenv.$(IMPLIBEXT): userenv/userenv.spec $(WINEBUILD) + @cd userenv && $(MAKE) libuserenv.$(IMPLIBEXT) + usp10/libusp10.$(IMPLIBEXT): usp10/usp10.spec $(WINEBUILD) @cd usp10 && $(MAKE) libusp10.$(IMPLIBEXT) diff --git a/dlls/userenv/Makefile.in b/dlls/userenv/Makefile.in index 9db0d69f5ea..946d2109b71 100644 --- a/dlls/userenv/Makefile.in +++ b/dlls/userenv/Makefile.in @@ -4,6 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = userenv.dll IMPORTS = kernel32 +IMPORTLIB = userenv C_SRCS = \ userenv_main.c diff --git a/dlls/userenv/tests/Makefile.in b/dlls/userenv/tests/Makefile.in new file mode 100644 index 00000000000..97202394956 --- /dev/null +++ b/dlls/userenv/tests/Makefile.in @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +TESTDLL = userenv.dll +IMPORTS = userenv advapi32 kernel32 + +CTESTS = \ + userenv.c + +@MAKE_TEST_RULES@ + +@DEPENDENCIES@ # everything below this line is overwritten by make depend diff --git a/dlls/userenv/tests/userenv.c b/dlls/userenv/tests/userenv.c new file mode 100644 index 00000000000..9f9425ac7f9 --- /dev/null +++ b/dlls/userenv/tests/userenv.c @@ -0,0 +1,59 @@ +/* + * Unit test suite for userenv functions + * + * Copyright 2008 Google (Lei Zhang) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include "windef.h" +#include "winbase.h" + +#include "userenv.h" + +#include "wine/test.h" + +#define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT)) + +static void test_create_env(void) +{ + BOOL r; + HANDLE htok; + WCHAR * env; + WCHAR * env2; + + r = CreateEnvironmentBlock(NULL, NULL, FALSE); + expect(FALSE, r); + + r = CreateEnvironmentBlock((LPVOID) &env, NULL, FALSE); + todo_wine expect(TRUE, r); + + r = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &htok); + expect(TRUE, r); + + r = CreateEnvironmentBlock(NULL, htok, FALSE); + expect(FALSE, r); + + r = CreateEnvironmentBlock((LPVOID) &env2, htok, FALSE); + todo_wine expect(TRUE, r); +} + +START_TEST(userenv) +{ + test_create_env(); +} diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in index 917c6f7144b..03c5dae92e2 100644 --- a/programs/winetest/Makefile.in +++ b/programs/winetest/Makefile.in @@ -95,6 +95,7 @@ TESTBINS = \ spoolss_test.exe \ urlmon_test.exe \ user32_test.exe \ + userenv_test.exe \ usp10_test.exe \ uxtheme_test.exe \ version_test.exe \ @@ -246,6 +247,8 @@ urlmon_test.exe: $(DLLDIR)/urlmon/tests/urlmon_test.exe$(DLLEXT) cp $(DLLDIR)/urlmon/tests/urlmon_test.exe$(DLLEXT) $@ && $(STRIP) $@ user32_test.exe: $(DLLDIR)/user32/tests/user32_test.exe$(DLLEXT) cp $(DLLDIR)/user32/tests/user32_test.exe$(DLLEXT) $@ && $(STRIP) $@ +userenv_test.exe: $(DLLDIR)/userenv/tests/userenv_test.exe$(DLLEXT) + cp $(DLLDIR)/userenv/tests/userenv_test.exe$(DLLEXT) $@ && $(STRIP) $@ usp10_test.exe: $(DLLDIR)/usp10/tests/usp10_test.exe$(DLLEXT) cp $(DLLDIR)/usp10/tests/usp10_test.exe$(DLLEXT) $@ && $(STRIP) $@ uxtheme_test.exe: $(DLLDIR)/uxtheme/tests/uxtheme_test.exe$(DLLEXT) diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc index 299e0e34e7c..05b28c3107d 100644 --- a/programs/winetest/winetest.rc +++ b/programs/winetest/winetest.rc @@ -156,6 +156,7 @@ snmpapi_test.exe TESTRES "snmpapi_test.exe" spoolss_test.exe TESTRES "spoolss_test.exe" urlmon_test.exe TESTRES "urlmon_test.exe" user32_test.exe TESTRES "user32_test.exe" +userenv_test.exe TESTRES "userenv_test.exe" usp10_test.exe TESTRES "usp10_test.exe" uxtheme_test.exe TESTRES "uxtheme_test.exe" version_test.exe TESTRES "version_test.exe"