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).
Esse commit está contido em:
@@ -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"
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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_
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
function VS($x, $y) {
|
||||
var_dump($x === $y);
|
||||
if ($x !== $y) { echo "Failed: $y\n"; echo "Got: $x\n";
|
||||
var_dump(debug_backtrace()); }
|
||||
}
|
||||
function VERIFY($x) { VS($x != false, true); }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
VERIFY(posix_access(__DIR__."/ext_posix.php"));
|
||||
|
||||
VERIFY(strlen(posix_ctermid()));
|
||||
VERIFY(strlen(posix_getcwd()));
|
||||
|
||||
$ret = posix_getgrgid(posix_getgid());
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
|
||||
$bynam = posix_getgrnam($ret['name']);
|
||||
VS($ret, $bynam);
|
||||
|
||||
$ret = posix_getgrnam("root");
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
|
||||
$bygid = posix_getgrgid($ret['gid']);
|
||||
VS($ret, $bygid);
|
||||
|
||||
// $ret = posix_getgroups();
|
||||
// VERIFY($ret != false);
|
||||
// VERIFY(count((array)$ret) != 0);
|
||||
|
||||
VERIFY(posix_getpgid(0));
|
||||
VERIFY(posix_getpgrp());
|
||||
VERIFY(posix_getpid());
|
||||
VERIFY(posix_getppid());
|
||||
|
||||
$ret = posix_getpwnam("root");
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
VS(posix_getpwnam(""), false);
|
||||
|
||||
$ret = posix_getpwuid(0);
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
VS(posix_getpwuid(-1), false);
|
||||
|
||||
$ret = posix_getrlimit();
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
|
||||
VERIFY(posix_getsid(posix_getpid()));
|
||||
|
||||
$tmpfifo = tempnam('/tmp', 'vmmkfifotest');
|
||||
unlink($tmpfifo);
|
||||
VERIFY(posix_mkfifo($tmpfifo, 0));
|
||||
|
||||
$tmpnod = tempnam('/tmp', 'vmmknodtest');
|
||||
unlink($tmpnod);
|
||||
VERIFY(posix_mknod($tmpnod, 0));
|
||||
|
||||
VERIFY(posix_setpgid(0, 0));
|
||||
VERIFY(posix_setsid());
|
||||
|
||||
VERIFY(strlen(posix_strerror(EPERM)));
|
||||
|
||||
$ret = posix_times();
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
|
||||
$ret = posix_uname();
|
||||
VERIFY($ret != false);
|
||||
VERIFY(count((array)$ret) != 0);
|
||||
@@ -0,0 +1,31 @@
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
Referência em uma Nova Issue
Bloquear um usuário