From edf410ad86bb14ee972193f4cfea9f9a4d1608ef Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Tue, 18 Jun 2013 14:52:54 -0700 Subject: [PATCH] Port TestExtPosix to php Dropped tests that just called functions and did no testing of the the result (the probability they'll catch a bug is around zero). --- hphp/test/ext/test_ext.h | 1 - hphp/test/ext/test_ext_posix.cpp | 271 ------------------ hphp/test/ext/test_ext_posix.h | 69 ----- hphp/test/slow/ext_posix/ext_posix.php | 76 +++++ hphp/test/slow/ext_posix/ext_posix.php.expect | 31 ++ 5 files changed, 107 insertions(+), 341 deletions(-) delete mode 100644 hphp/test/ext/test_ext_posix.cpp delete mode 100644 hphp/test/ext/test_ext_posix.h create mode 100644 hphp/test/slow/ext_posix/ext_posix.php create mode 100644 hphp/test/slow/ext_posix/ext_posix.php.expect diff --git a/hphp/test/ext/test_ext.h b/hphp/test/ext/test_ext.h index 1046e1bc9..78ca54048 100644 --- a/hphp/test/ext/test_ext.h +++ b/hphp/test/ext/test_ext.h @@ -23,7 +23,6 @@ #include "hphp/test/ext/test_ext_memcached.h" #include "hphp/test/ext/test_ext_mysql.h" #include "hphp/test/ext/test_ext_pdo.h" -#include "hphp/test/ext/test_ext_posix.h" #include "hphp/test/ext/test_ext_process.h" #include "hphp/test/ext/test_ext_server.h" diff --git a/hphp/test/ext/test_ext_posix.cpp b/hphp/test/ext/test_ext_posix.cpp deleted file mode 100644 index 0b94f7638..000000000 --- a/hphp/test/ext/test_ext_posix.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | HipHop for PHP | - +----------------------------------------------------------------------+ - | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ -*/ - -#include "hphp/test/ext/test_ext_posix.h" -#include "hphp/runtime/ext/ext_posix.h" -#include "hphp/runtime/ext/ext_file.h" - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtPosix::RunTests(const std::string &which) { - bool ret = true; - - RUN_TEST(test_posix_access); - RUN_TEST(test_posix_ctermid); - RUN_TEST(test_posix_get_last_error); - RUN_TEST(test_posix_getcwd); - RUN_TEST(test_posix_getegid); - RUN_TEST(test_posix_geteuid); - RUN_TEST(test_posix_getgid); - RUN_TEST(test_posix_getgrgid); - RUN_TEST(test_posix_getgrnam); - RUN_TEST(test_posix_getgroups); - RUN_TEST(test_posix_getlogin); - RUN_TEST(test_posix_getpgid); - RUN_TEST(test_posix_getpgrp); - RUN_TEST(test_posix_getpid); - RUN_TEST(test_posix_getppid); - RUN_TEST(test_posix_getpwnam); - RUN_TEST(test_posix_getpwuid); - RUN_TEST(test_posix_getrlimit); - RUN_TEST(test_posix_getsid); - RUN_TEST(test_posix_getuid); - RUN_TEST(test_posix_initgroups); - RUN_TEST(test_posix_isatty); - RUN_TEST(test_posix_kill); - RUN_TEST(test_posix_mkfifo); - RUN_TEST(test_posix_mknod); - RUN_TEST(test_posix_setegid); - RUN_TEST(test_posix_seteuid); - RUN_TEST(test_posix_setgid); - RUN_TEST(test_posix_setpgid); - RUN_TEST(test_posix_setsid); - RUN_TEST(test_posix_setuid); - RUN_TEST(test_posix_strerror); - RUN_TEST(test_posix_times); - RUN_TEST(test_posix_ttyname); - RUN_TEST(test_posix_uname); - - return ret; -} - -/////////////////////////////////////////////////////////////////////////////// - -bool TestExtPosix::test_posix_access() { - VERIFY(f_posix_access("test/ext/test_ext_posix.cpp")); - return Count(true); -} - -bool TestExtPosix::test_posix_ctermid() { - VERIFY(!f_posix_ctermid().empty()); - return Count(true); -} - -bool TestExtPosix::test_posix_get_last_error() { - errno = 0; - VERIFY(!f_posix_get_last_error()); - return Count(true); -} - -bool TestExtPosix::test_posix_getcwd() { - VERIFY(!f_posix_getcwd().empty()); - return Count(true); -} - -bool TestExtPosix::test_posix_getegid() { - f_posix_getegid(); - return Count(true); -} - -bool TestExtPosix::test_posix_geteuid() { - f_posix_geteuid(); - return Count(true); -} - -bool TestExtPosix::test_posix_getgid() { - f_posix_getgid(); - return Count(true); -} - -bool TestExtPosix::test_posix_getgrgid() { - static const StaticString s_name("name"); - Variant ret = f_posix_getgrgid(f_posix_getgid()); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - - Variant bynam = f_posix_getgrnam(ret[s_name]); - VS(ret, bynam); - - return Count(true); -} - -bool TestExtPosix::test_posix_getgrnam() { - static const StaticString s_gid("gid"); - Variant ret = f_posix_getgrnam("root"); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - - Variant bygid = f_posix_getgrgid(ret[s_gid]); - VS(ret, bygid); - - return Count(true); -} - -bool TestExtPosix::test_posix_getgroups() { - Variant ret = f_posix_getgroups(); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - return Count(true); -} - -bool TestExtPosix::test_posix_getlogin() { - f_posix_getlogin(); - return Count(true); -} - -bool TestExtPosix::test_posix_getpgid() { - VERIFY(f_posix_getpgid(0)); - return Count(true); -} - -bool TestExtPosix::test_posix_getpgrp() { - VERIFY(f_posix_getpgrp()); - return Count(true); -} - -bool TestExtPosix::test_posix_getpid() { - VERIFY(f_posix_getpid()); - return Count(true); -} - -bool TestExtPosix::test_posix_getppid() { - VERIFY(f_posix_getppid()); - return Count(true); -} - -bool TestExtPosix::test_posix_getpwnam() { - Variant ret = f_posix_getpwnam("root"); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - VS(f_posix_getpwnam(""), false); - return Count(true); -} - -bool TestExtPosix::test_posix_getpwuid() { - Variant ret = f_posix_getpwuid(0); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - VS(f_posix_getpwuid(-1), false); - return Count(true); -} - -bool TestExtPosix::test_posix_getrlimit() { - Variant ret = f_posix_getrlimit(); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - return Count(true); -} - -bool TestExtPosix::test_posix_getsid() { - VERIFY(f_posix_getsid(getpid())); - return Count(true); -} - -bool TestExtPosix::test_posix_getuid() { - f_posix_getuid(); - return Count(true); -} - -bool TestExtPosix::test_posix_initgroups() { - f_posix_initgroups("root", 100); - return Count(true); -} - -bool TestExtPosix::test_posix_isatty() { - f_posix_isatty(1); - return Count(true); -} - -bool TestExtPosix::test_posix_kill() { - //VERIFY(f_posix_kill(-1, 9)); - return Count(true); -} - -bool TestExtPosix::test_posix_mkfifo() { - remove("/tmp/test_posix_mkfifo"); - VERIFY(f_posix_mkfifo("/tmp/test_posix_mkfifo", 0)); - return Count(true); -} - -bool TestExtPosix::test_posix_mknod() { - remove("/tmp/test_posix_mknod"); - VERIFY(f_posix_mknod("/tmp/test_posix_mknod", 0)); - return Count(true); -} - -bool TestExtPosix::test_posix_setegid() { - f_posix_setegid(0); - return Count(true); -} - -bool TestExtPosix::test_posix_seteuid() { - f_posix_seteuid(0); - return Count(true); -} - -bool TestExtPosix::test_posix_setgid() { - f_posix_setgid(0); - return Count(true); -} - -bool TestExtPosix::test_posix_setpgid() { - VERIFY(f_posix_setpgid(0, 0)); - return Count(true); -} - -bool TestExtPosix::test_posix_setsid() { - VERIFY(f_posix_setsid()); - return Count(true); -} - -bool TestExtPosix::test_posix_setuid() { - f_posix_setuid(0); - return Count(true); -} - -bool TestExtPosix::test_posix_strerror() { - VERIFY(!f_posix_strerror(EPERM).empty()); - return Count(true); -} - -bool TestExtPosix::test_posix_times() { - Variant ret = f_posix_times(); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - return Count(true); -} - -bool TestExtPosix::test_posix_ttyname() { - // Jenkins doesn't have real ttys to test this with - return Count(true); -} - -bool TestExtPosix::test_posix_uname() { - Variant ret = f_posix_uname(); - VERIFY(!same(ret, false)); - VERIFY(!ret.toArray().empty()); - return Count(true); -} diff --git a/hphp/test/ext/test_ext_posix.h b/hphp/test/ext/test_ext_posix.h deleted file mode 100644 index 99858de91..000000000 --- a/hphp/test/ext/test_ext_posix.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | HipHop for PHP | - +----------------------------------------------------------------------+ - | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ -*/ - -#ifndef incl_HPHP_TEST_EXT_POSIX_H_ -#define incl_HPHP_TEST_EXT_POSIX_H_ - -// >>>>>> Generated by idl.php. Do NOT modify. <<<<<< - -#include "hphp/test/ext/test_cpp_ext.h" - -/////////////////////////////////////////////////////////////////////////////// - -class TestExtPosix : public TestCppExt { - public: - virtual bool RunTests(const std::string &which); - - bool test_posix_access(); - bool test_posix_ctermid(); - bool test_posix_get_last_error(); - bool test_posix_getcwd(); - bool test_posix_getegid(); - bool test_posix_geteuid(); - bool test_posix_getgid(); - bool test_posix_getgrgid(); - bool test_posix_getgrnam(); - bool test_posix_getgroups(); - bool test_posix_getlogin(); - bool test_posix_getpgid(); - bool test_posix_getpgrp(); - bool test_posix_getpid(); - bool test_posix_getppid(); - bool test_posix_getpwnam(); - bool test_posix_getpwuid(); - bool test_posix_getrlimit(); - bool test_posix_getsid(); - bool test_posix_getuid(); - bool test_posix_initgroups(); - bool test_posix_isatty(); - bool test_posix_kill(); - bool test_posix_mkfifo(); - bool test_posix_mknod(); - bool test_posix_setegid(); - bool test_posix_seteuid(); - bool test_posix_setgid(); - bool test_posix_setpgid(); - bool test_posix_setsid(); - bool test_posix_setuid(); - bool test_posix_strerror(); - bool test_posix_times(); - bool test_posix_ttyname(); - bool test_posix_uname(); -}; - -/////////////////////////////////////////////////////////////////////////////// - -#endif // incl_HPHP_TEST_EXT_POSIX_H_ diff --git a/hphp/test/slow/ext_posix/ext_posix.php b/hphp/test/slow/ext_posix/ext_posix.php new file mode 100644 index 000000000..9de70b686 --- /dev/null +++ b/hphp/test/slow/ext_posix/ext_posix.php @@ -0,0 +1,76 @@ +