Move TestExtMath to php
[hiphop-php.git] / hphp / test / ext / test_ext_options.cpp
blob2d551b561388b71ade59ce8f974f28a7b675f238
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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) {
23 bool ret = true;
25 DECLARE_TEST_FUNCTIONS("");
27 RUN_TEST(test_assert_options);
28 RUN_TEST(test_assert);
29 RUN_TEST(test_dl);
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);
80 return ret;
83 ///////////////////////////////////////////////////////////////////////////////
85 bool TestExtOptions::test_assert_options() {
86 f_assert_options(1);
87 return Count(true);
90 bool TestExtOptions::test_assert() {
91 f_assert(true);
92 try {
93 f_assert(false);
94 } catch (const Assertion& e) {
95 return Count(true);
97 return Count(true);
100 bool TestExtOptions::test_dl() {
101 VS(f_dl(""), 0);
102 return Count(true);
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"));
111 return Count(true);
114 bool TestExtOptions::test_get_loaded_extensions() {
115 VERIFY(!f_get_loaded_extensions().empty());
116 return Count(true);
119 bool TestExtOptions::test_get_extension_funcs() {
120 try {
121 f_get_extension_funcs("");
122 } catch (const NotSupportedException& e) {
123 return Count(true);
125 return Count(false);
128 bool TestExtOptions::test_get_cfg_var() {
129 VERIFY(!f_get_cfg_var(""))
130 return Count(true);
133 bool TestExtOptions::test_get_current_user() {
134 f_get_current_user();
135 return Count(true);
138 bool TestExtOptions::test_get_defined_constants() {
139 try {
140 f_get_defined_constants(true);
141 return Count(false);
142 } catch (const NotSupportedException& e) {
143 return Count(true);
145 f_get_defined_constants();
146 return Count(true);
149 bool TestExtOptions::test_get_include_path() {
150 f_get_include_path();
151 return Count(true);
154 bool TestExtOptions::test_restore_include_path() {
155 f_restore_include_path();
156 return Count(true);
159 bool TestExtOptions::test_set_include_path() {
160 f_set_include_path("");
161 return Count(true);
164 bool TestExtOptions::test_get_included_files() {
165 VS(f_get_included_files(), Array::Create());
166 return Count(true);
169 bool TestExtOptions::test_inclued_get_data() {
170 VS(f_inclued_get_data(), Array::Create());
171 return Count(true);
174 bool TestExtOptions::test_get_magic_quotes_gpc() {
175 VS(f_get_magic_quotes_gpc(), 0);
176 return Count(true);
179 bool TestExtOptions::test_get_magic_quotes_runtime() {
180 VS(f_get_magic_quotes_runtime(), 0);
181 return Count(true);
184 bool TestExtOptions::test_get_required_files() {
185 try {
186 f_get_required_files();
187 } catch (const NotSupportedException& e) {
188 return Count(true);
190 return Count(false);
193 bool TestExtOptions::test_getenv() {
194 VS(f_getenv("NOTTHERE"), false);
195 return Count(true);
198 bool TestExtOptions::test_getlastmod() {
199 try {
200 f_getlastmod();
201 } catch (const NotSupportedException& e) {
202 return Count(true);
204 return Count(false);
207 bool TestExtOptions::test_getmygid() {
208 f_getmygid();
209 return Count(true);
212 bool TestExtOptions::test_getmyinode() {
213 try {
214 f_getmyinode();
215 } catch (const NotSupportedException& e) {
216 return Count(true);
218 return Count(false);
221 bool TestExtOptions::test_getmypid() {
222 VERIFY(f_getmypid());
223 return Count(true);
226 bool TestExtOptions::test_getmyuid() {
227 f_getmyuid();
228 return Count(true);
231 bool TestExtOptions::test_getopt() {
232 f_getopt("");
233 return Count(true);
236 bool TestExtOptions::test_getrusage() {
237 VERIFY(!f_getrusage().empty());
238 return Count(true);
241 bool TestExtOptions::test_clock_getres() {
242 Variant sec, nsec;
243 VERIFY(f_clock_getres(k_CLOCK_THREAD_CPUTIME_ID, ref(sec), ref(nsec)));
244 VS(sec, 0);
245 VS(nsec, 1);
246 return Count(true);
249 bool TestExtOptions::test_clock_gettime() {
250 Variant sec, nsec;
251 VERIFY(f_clock_gettime(k_CLOCK_THREAD_CPUTIME_ID, ref(sec), ref(nsec)));
252 return Count(true);
255 bool TestExtOptions::test_clock_settime() {
256 f_clock_settime(k_CLOCK_THREAD_CPUTIME_ID, 100, 100);
257 return Count(true);
260 bool TestExtOptions::test_cpu_get_count() {
261 VERIFY(f_cpu_get_count() > 0);
262 return Count(true);
265 bool TestExtOptions::test_cpu_get_model() {
266 VERIFY(!f_cpu_get_model().empty());
267 return Count(true);
270 bool TestExtOptions::test_ini_alter() {
271 try {
272 f_ini_alter("", "");
273 } catch (const NotSupportedException& e) {
274 return Count(true);
276 return Count(false);
279 bool TestExtOptions::test_ini_get_all() {
280 try {
281 f_ini_get_all();
282 } catch (const NotSupportedException& e) {
283 return Count(true);
285 return Count(false);
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");
296 return Count(true);
299 bool TestExtOptions::test_ini_restore() {
300 f_ini_restore("");
301 return Count(true);
304 bool TestExtOptions::test_ini_set() {
305 f_ini_set("", "");
306 return Count(true);
309 bool TestExtOptions::test_memory_get_peak_usage() {
310 f_memory_get_peak_usage();
311 return Count(true);
314 bool TestExtOptions::test_memory_get_usage() {
315 f_memory_get_usage();
316 return Count(true);
319 bool TestExtOptions::test_php_ini_scanned_files() {
320 try {
321 f_php_ini_scanned_files();
322 } catch (const NotSupportedException& e) {
323 return Count(true);
325 return Count(false);
328 bool TestExtOptions::test_php_logo_guid() {
329 try {
330 f_php_logo_guid();
331 } catch (const NotSupportedException& e) {
332 return Count(true);
334 return Count(false);
337 bool TestExtOptions::test_php_sapi_name() {
338 f_php_sapi_name();
339 return Count(true);
342 bool TestExtOptions::test_php_uname() {
343 VERIFY(!f_php_uname().empty());
344 return Count(true);
347 bool TestExtOptions::test_phpcredits() {
348 try {
349 f_phpcredits();
350 } catch (const NotSupportedException& e) {
351 return Count(true);
353 return Count(false);
356 bool TestExtOptions::test_phpinfo() {
357 //f_phpinfo();
358 return Count(true);
361 bool TestExtOptions::test_phpversion() {
362 VS(f_phpversion(), "5.4.999-hiphop");
363 return Count(true);
366 bool TestExtOptions::test_putenv() {
367 VERIFY(f_putenv("FOO=bar"));
368 VERIFY(!f_putenv("FOO"));
369 return Count(true);
372 bool TestExtOptions::test_set_magic_quotes_runtime() {
373 f_set_magic_quotes_runtime(false);
374 return Count(true);
377 bool TestExtOptions::test_set_time_limit() {
378 f_set_time_limit(2);
379 return Count(true);
382 bool TestExtOptions::test_sys_get_temp_dir() {
383 VERIFY(f_sys_get_temp_dir() == "/tmp");
384 return Count(true);
387 bool TestExtOptions::test_version_compare() {
388 VERIFY(!f_version_compare("1.3.0.dev", "1.1.2", "<"));
389 return Count(true);
392 bool TestExtOptions::test_zend_logo_guid() {
393 try {
394 f_zend_logo_guid();
395 } catch (const NotSupportedException& e) {
396 return Count(true);
398 return Count(false);
401 bool TestExtOptions::test_zend_thread_id() {
402 try {
403 f_zend_thread_id();
404 } catch (const NotSupportedException& e) {
405 return Count(true);
407 return Count(false);
410 bool TestExtOptions::test_zend_version() {
411 try {
412 f_zend_version();
413 } catch (const NotSupportedException& e) {
414 return Count(true);
416 return Count(false);