1--TEST--
2mysqli_debug() - enabling trace with ini setting
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8
9if (!function_exists('mysqli_debug'))
10    die("skip mysqli_debug() not available");
11
12if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
13    die("skip: can't say for sure if mysqli_debug works");
14
15if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
16    die("skip: debug functionality not enabled");
17
18if (!$fp = @fopen('/tmp/mysqli_debug_phpt.trace', 'w'))
19    die("skip PHP cannot create a file in /tmp/mysqli_debug_phpt");
20else
21    fclose($fp);
22@unlink("/tmp/mysqli_debug_phpt.trace");
23?>
24--INI--
25mysqlnd.debug="t:O,/tmp/mysqli_debug_phpt.trace"
26--FILE--
27<?php
28    require_once 'table.inc';
29
30    var_dump(ini_get('mysqlnd.debug'));
31
32    $trace_file = '/tmp/mysqli_debug_phpt.trace';
33    clearstatcache();
34    if (!file_exists($trace_file))
35        printf("[003] Trace file '%s' has not been created\n", $trace_file);
36    if (filesize($trace_file) < 50)
37        printf("[004] Trace file '%s' is very small. filesize() reports only %d bytes. Please check.\n",
38            $trace_file,
39            filesize($trace_file));
40
41    mysqli_close($link);
42    unlink($trace_file);
43
44    print "done!";
45?>
46--CLEAN--
47<?php
48require_once 'clean_table.inc';
49?>
50--EXPECT--
51string(32) "t:O,/tmp/mysqli_debug_phpt.trace"
52done!
53