2007-03-06 11:59:18 +00:00
|
|
|
/*
|
|
|
|
* Unit tests for C library environment routines
|
|
|
|
*
|
|
|
|
* Copyright 2004 Mike Hearn <mh@codeweavers.com>
|
|
|
|
*
|
|
|
|
* 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
|
2007-11-04 15:54:33 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2007-03-06 11:59:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-11-04 15:54:33 +00:00
|
|
|
static const char *a_very_long_env_string =
|
|
|
|
"LIBRARY_PATH="
|
|
|
|
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/;"
|
|
|
|
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/;"
|
|
|
|
"/mingw/lib/gcc/mingw32/3.4.2/;"
|
|
|
|
"/usr/lib/gcc/mingw32/3.4.2/;"
|
|
|
|
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/mingw32/3.4.2/;"
|
|
|
|
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/lib/;"
|
|
|
|
"/mingw/mingw32/lib/mingw32/3.4.2/;"
|
|
|
|
"/mingw/mingw32/lib/;"
|
|
|
|
"/mingw/lib/mingw32/3.4.2/;"
|
|
|
|
"/mingw/lib/;"
|
|
|
|
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../mingw32/3.4.2/;"
|
|
|
|
"C:/Program Files/GLBasic/Compiler/platform/Win32/Bin/../lib/gcc/mingw32/3.4.2/../../../;"
|
|
|
|
"/mingw/lib/mingw32/3.4.2/;"
|
|
|
|
"/mingw/lib/;"
|
|
|
|
"/lib/mingw32/3.4.2/;"
|
|
|
|
"/lib/;"
|
|
|
|
"/usr/lib/mingw32/3.4.2/;"
|
|
|
|
"/usr/lib/";
|
|
|
|
|
2010-05-29 09:22:07 +00:00
|
|
|
static void test_system(void)
|
|
|
|
{
|
|
|
|
int ret = system(NULL);
|
|
|
|
ok(ret == 1, "Expected system to return 1, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = system("echo OK");
|
|
|
|
ok(ret == 0, "Expected system to return 0, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2007-03-06 11:59:18 +00:00
|
|
|
START_TEST(environ)
|
|
|
|
{
|
|
|
|
ok( _putenv("cat=") == 0, "_putenv failed on deletion of nonexistent environment variable\n" );
|
|
|
|
ok( _putenv("cat=dog") == 0, "failed setting cat=dog\n" );
|
|
|
|
ok( strcmp(getenv("cat"), "dog") == 0, "getenv did not return 'dog'\n" );
|
|
|
|
ok( _putenv("cat=") == 0, "failed deleting cat\n" );
|
|
|
|
|
|
|
|
ok( _putenv("=") == -1, "should not accept '=' as input\n" );
|
|
|
|
ok( _putenv("=dog") == -1, "should not accept '=dog' as input\n" );
|
2007-11-04 15:54:33 +00:00
|
|
|
ok( _putenv(a_very_long_env_string) == 0, "_putenv failed for long environment string\n");
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
ok( getenv("nonexistent") == NULL, "getenv should fail with nonexistent var name\n" );
|
2010-05-29 09:22:07 +00:00
|
|
|
|
|
|
|
test_system();
|
2007-03-06 11:59:18 +00:00
|
|
|
}
|