2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/test/ext/test_ext_options.h"
18 #include "hphp/runtime/ext/ext_options.h"
20 ///////////////////////////////////////////////////////////////////////////////
22 bool TestExtOptions::RunTests(const std::string
&which
) {
25 DECLARE_TEST_FUNCTIONS("");
27 RUN_TEST(test_assert_options
);
28 RUN_TEST(test_assert
);
30 RUN_TEST(test_extension_loaded
);
31 RUN_TEST(test_get_loaded_extensions
);
32 RUN_TEST(test_get_extension_funcs
);
33 RUN_TEST(test_get_cfg_var
);
34 RUN_TEST(test_get_current_user
);
35 RUN_TEST(test_get_defined_constants
);
36 RUN_TEST(test_get_include_path
);
37 RUN_TEST(test_restore_include_path
);
38 RUN_TEST(test_set_include_path
);
39 RUN_TEST(test_get_included_files
);
40 RUN_TEST(test_inclued_get_data
);
41 RUN_TEST(test_get_magic_quotes_gpc
);
42 RUN_TEST(test_get_magic_quotes_runtime
);
43 RUN_TEST(test_get_required_files
);
44 RUN_TEST(test_getenv
);
45 RUN_TEST(test_getlastmod
);
46 RUN_TEST(test_getmygid
);
47 RUN_TEST(test_getmyinode
);
48 RUN_TEST(test_getmypid
);
49 RUN_TEST(test_getmyuid
);
50 RUN_TEST(test_getopt
);
51 RUN_TEST(test_getrusage
);
52 RUN_TEST(test_clock_getres
);
53 RUN_TEST(test_clock_gettime
);
54 RUN_TEST(test_clock_settime
);
55 RUN_TEST(test_cpu_get_count
);
56 RUN_TEST(test_cpu_get_model
);
57 RUN_TEST(test_ini_alter
);
58 RUN_TEST(test_ini_get_all
);
59 RUN_TEST(test_ini_get
);
60 RUN_TEST(test_ini_restore
);
61 RUN_TEST(test_ini_set
);
62 RUN_TEST(test_memory_get_peak_usage
);
63 RUN_TEST(test_memory_get_usage
);
64 RUN_TEST(test_php_ini_scanned_files
);
65 RUN_TEST(test_php_logo_guid
);
66 RUN_TEST(test_php_sapi_name
);
67 RUN_TEST(test_php_uname
);
68 RUN_TEST(test_phpcredits
);
69 RUN_TEST(test_phpinfo
);
70 RUN_TEST(test_phpversion
);
71 RUN_TEST(test_putenv
);
72 RUN_TEST(test_set_magic_quotes_runtime
);
73 RUN_TEST(test_set_time_limit
);
74 RUN_TEST(test_sys_get_temp_dir
);
75 RUN_TEST(test_version_compare
);
76 RUN_TEST(test_zend_logo_guid
);
77 RUN_TEST(test_zend_thread_id
);
78 RUN_TEST(test_zend_version
);
83 ///////////////////////////////////////////////////////////////////////////////
85 bool TestExtOptions::test_assert_options() {
90 bool TestExtOptions::test_assert() {
94 } catch (const Assertion
& e
) {
100 bool TestExtOptions::test_dl() {
105 bool TestExtOptions::test_extension_loaded() {
106 VERIFY(f_extension_loaded("phpmcc"));
107 VERIFY(f_extension_loaded("bcmath"));
108 VERIFY(f_extension_loaded("curl"));
109 VERIFY(f_extension_loaded("simplexml"));
110 VERIFY(f_extension_loaded("mysql"));
114 bool TestExtOptions::test_get_loaded_extensions() {
115 VERIFY(!f_get_loaded_extensions().empty());
119 bool TestExtOptions::test_get_extension_funcs() {
121 f_get_extension_funcs("");
122 } catch (const NotSupportedException
& e
) {
128 bool TestExtOptions::test_get_cfg_var() {
129 VERIFY(!f_get_cfg_var(""))
133 bool TestExtOptions::test_get_current_user() {
134 f_get_current_user();
138 bool TestExtOptions::test_get_defined_constants() {
140 f_get_defined_constants(true);
142 } catch (const NotSupportedException
& e
) {
145 f_get_defined_constants();
149 bool TestExtOptions::test_get_include_path() {
150 f_get_include_path();
154 bool TestExtOptions::test_restore_include_path() {
155 f_restore_include_path();
159 bool TestExtOptions::test_set_include_path() {
160 f_set_include_path("");
164 bool TestExtOptions::test_get_included_files() {
165 VS(f_get_included_files(), Array::Create());
169 bool TestExtOptions::test_inclued_get_data() {
170 VS(f_inclued_get_data(), Array::Create());
174 bool TestExtOptions::test_get_magic_quotes_gpc() {
175 VS(f_get_magic_quotes_gpc(), 0);
179 bool TestExtOptions::test_get_magic_quotes_runtime() {
180 VS(f_get_magic_quotes_runtime(), 0);
184 bool TestExtOptions::test_get_required_files() {
186 f_get_required_files();
187 } catch (const NotSupportedException
& e
) {
193 bool TestExtOptions::test_getenv() {
194 VS(f_getenv("NOTTHERE"), false);
198 bool TestExtOptions::test_getlastmod() {
201 } catch (const NotSupportedException
& e
) {
207 bool TestExtOptions::test_getmygid() {
212 bool TestExtOptions::test_getmyinode() {
215 } catch (const NotSupportedException
& e
) {
221 bool TestExtOptions::test_getmypid() {
222 VERIFY(f_getmypid());
226 bool TestExtOptions::test_getmyuid() {
231 bool TestExtOptions::test_getopt() {
236 bool TestExtOptions::test_getrusage() {
237 VERIFY(!f_getrusage().empty());
241 bool TestExtOptions::test_clock_getres() {
243 VERIFY(f_clock_getres(k_CLOCK_THREAD_CPUTIME_ID
, ref(sec
), ref(nsec
)));
249 bool TestExtOptions::test_clock_gettime() {
251 VERIFY(f_clock_gettime(k_CLOCK_THREAD_CPUTIME_ID
, ref(sec
), ref(nsec
)));
255 bool TestExtOptions::test_clock_settime() {
256 f_clock_settime(k_CLOCK_THREAD_CPUTIME_ID
, 100, 100);
260 bool TestExtOptions::test_cpu_get_count() {
261 VERIFY(f_cpu_get_count() > 0);
265 bool TestExtOptions::test_cpu_get_model() {
266 VERIFY(!f_cpu_get_model().empty());
270 bool TestExtOptions::test_ini_alter() {
273 } catch (const NotSupportedException
& e
) {
279 bool TestExtOptions::test_ini_get_all() {
282 } catch (const NotSupportedException
& e
) {
288 bool TestExtOptions::test_ini_get() {
289 VS(f_ini_get(""), "");
290 f_ini_set("memory_limit", 50000000);
291 VS(f_ini_get("memory_limit"), "50000000");
292 f_set_time_limit(30);
293 VS(f_ini_get("max_execution_time"), "30");
294 f_ini_set("max_execution_time", 40);
295 VS(f_ini_get("max_execution_time"), "40");
299 bool TestExtOptions::test_ini_restore() {
304 bool TestExtOptions::test_ini_set() {
309 bool TestExtOptions::test_memory_get_peak_usage() {
310 f_memory_get_peak_usage();
314 bool TestExtOptions::test_memory_get_usage() {
315 f_memory_get_usage();
319 bool TestExtOptions::test_php_ini_scanned_files() {
321 f_php_ini_scanned_files();
322 } catch (const NotSupportedException
& e
) {
328 bool TestExtOptions::test_php_logo_guid() {
331 } catch (const NotSupportedException
& e
) {
337 bool TestExtOptions::test_php_sapi_name() {
342 bool TestExtOptions::test_php_uname() {
343 VERIFY(!f_php_uname().empty());
347 bool TestExtOptions::test_phpcredits() {
350 } catch (const NotSupportedException
& e
) {
356 bool TestExtOptions::test_phpinfo() {
361 bool TestExtOptions::test_phpversion() {
362 VS(f_phpversion(), "5.4.999-hiphop");
366 bool TestExtOptions::test_putenv() {
367 VERIFY(f_putenv("FOO=bar"));
368 VERIFY(!f_putenv("FOO"));
372 bool TestExtOptions::test_set_magic_quotes_runtime() {
373 f_set_magic_quotes_runtime(false);
377 bool TestExtOptions::test_set_time_limit() {
382 bool TestExtOptions::test_sys_get_temp_dir() {
383 VERIFY(f_sys_get_temp_dir() == "/tmp");
387 bool TestExtOptions::test_version_compare() {
388 VERIFY(!f_version_compare("1.3.0.dev", "1.1.2", "<"));
392 bool TestExtOptions::test_zend_logo_guid() {
395 } catch (const NotSupportedException
& e
) {
401 bool TestExtOptions::test_zend_thread_id() {
404 } catch (const NotSupportedException
& e
) {
410 bool TestExtOptions::test_zend_version() {
413 } catch (const NotSupportedException
& e
) {