Skip to content

Commit 0c4bb8a

Browse files
author
Martin Köditz
authored
Merge pull request #39 from Jon4t4n/ci
Add CI and fix/disable broken tests
2 parents b6c2883 + 62d5269 commit 0c4bb8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+682
-154
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Install
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
export DEBIAN_FRONTEND="noninteractive"
8+
sudo apt-get update
9+
sudo apt-get -y -q install firebird-dev firebird3.0 firebird3.0-common firebird3.0-server
10+
FB_ORIGINAL_PASS=`sudo cat /etc/firebird/3.0/SYSDBA.password | grep ISC_PASSWORD | sed -e 's/ISC_PASSWORD="\([^"]*\)".*/\1/'`
11+
gsec -user SYSDBA -password ${FB_ORIGINAL_PASS} -modify sysdba -pw masterkey
12+
sudo service firebird3.0 restart
13+
sudo apt-get -y install pkg-config build-essential autoconf bison re2c libxml2-dev libsqlite3-dev

.github/workflows/main.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
on:
2+
push:
3+
pull_request:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
jobs:
8+
linux:
9+
runs-on: ubuntu-latest
10+
continue-on-error: false
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: ['7.4', '8.0', '8.1', '8.2']
15+
steps:
16+
- name: Checkout php-src
17+
uses: actions/checkout@v3
18+
with:
19+
repository: 'php/php-src'
20+
ref: 'PHP-${{ matrix.php }}'
21+
- name: Checkout php-firebird
22+
uses: actions/checkout@v3
23+
with:
24+
path: 'ext/php-firebird'
25+
- name: Install dependencies
26+
uses: ./ext/php-firebird/.github/actions/install-linux
27+
- name: Build
28+
run: |
29+
./buildconf --force
30+
./configure --disable-all --with-interbase
31+
make -j$(/usr/bin/nproc)
32+
- name: Test
33+
run: sudo make test TESTS='ext/php-firebird --show-diff'
34+
linux-debug:
35+
runs-on: ubuntu-latest
36+
continue-on-error: false
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
php: ['7.4', '8.0', '8.1', '8.2']
41+
steps:
42+
- name: Checkout php-src
43+
uses: actions/checkout@v3
44+
with:
45+
repository: 'php/php-src'
46+
ref: 'PHP-${{ matrix.php }}'
47+
- name: Checkout php-firebird
48+
uses: actions/checkout@v3
49+
with:
50+
path: 'ext/php-firebird'
51+
- name: Install dependencies
52+
uses: ./ext/php-firebird/.github/actions/install-linux
53+
- name: Build
54+
run: |
55+
./buildconf --force
56+
./configure --disable-all --with-interbase --enable-debug
57+
make -j$(/usr/bin/nproc)
58+
- name: Test
59+
run: sudo make test TESTS='ext/php-firebird --show-diff'
60+

interbase.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_drop_db, 0, 0, 0)
8787
ZEND_END_ARG_INFO()
8888

8989
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_trans, 0, 0, 0)
90-
ZEND_ARG_INFO(0, trans_args)
9190
ZEND_ARG_INFO(0, link_identifier)
9291
ZEND_ARG_INFO(0, trans_args)
93-
ZEND_ARG_INFO(0, link_identifier)
9492
ZEND_END_ARG_INFO()
9593

96-
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit, 0, 0, 1)
94+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit, 0, 0, 0)
9795
ZEND_ARG_INFO(0, link_identifier)
9896
ZEND_END_ARG_INFO()
9997

100-
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback, 0, 0, 1)
98+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback, 0, 0, 0)
10199
ZEND_ARG_INFO(0, link_identifier)
102100
ZEND_END_ARG_INFO()
103101

104-
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit_ret, 0, 0, 1)
102+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit_ret, 0, 0, 0)
105103
ZEND_ARG_INFO(0, link_identifier)
106104
ZEND_END_ARG_INFO()
107105

108-
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback_ret, 0, 0, 1)
106+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback_ret, 0, 0, 0)
109107
ZEND_ARG_INFO(0, link_identifier)
110108
ZEND_END_ARG_INFO()
111109

@@ -158,11 +156,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_import, 0, 0, 0)
158156
ZEND_END_ARG_INFO()
159157

160158
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_query, 0, 0, 0)
161-
ZEND_ARG_INFO(0, link_identifier)
162159
ZEND_ARG_INFO(0, link_identifier)
163160
ZEND_ARG_INFO(0, query)
164-
ZEND_ARG_INFO(0, bind_arg)
165-
ZEND_ARG_INFO(0, bind_arg)
161+
ZEND_ARG_VARIADIC_INFO(0, bind_arg)
166162
ZEND_END_ARG_INFO()
167163

168164
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_affected_rows, 0, 0, 0)
@@ -206,8 +202,7 @@ ZEND_END_ARG_INFO()
206202

207203
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_execute, 0, 0, 1)
208204
ZEND_ARG_INFO(0, query)
209-
ZEND_ARG_INFO(0, bind_arg)
210-
ZEND_ARG_INFO(0, bind_arg)
205+
ZEND_ARG_VARIADIC_INFO(0, bind_arg)
211206
ZEND_END_ARG_INFO()
212207

213208
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_free_query, 0, 0, 1)
@@ -764,6 +759,11 @@ PHP_MINIT_FUNCTION(ibase)
764759
php_ibase_events_minit(INIT_FUNC_ARGS_PASSTHRU);
765760
php_ibase_service_minit(INIT_FUNC_ARGS_PASSTHRU);
766761

762+
#ifdef ZEND_SIGNALS
763+
// firebird replaces some signals at runtime, suppress warnings.
764+
SIGG(check) = 0;
765+
#endif
766+
767767
return SUCCESS;
768768
}
769769

tests/003.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ InterBase: misc sql types (may take a while)
4646
$v_double = rand_number(18);
4747
$v_float = rand_number(7);
4848
$v_integer = rand_number(9,0);
49-
$v_smallint = rand_number(5) % 32767;
49+
$v_smallint = ((int)rand_number(5)) % 32767;
5050
$v_varchar = rand_str(10000);
5151

5252
ibase_query(

tests/004.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
InterBase: BLOB test
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php die("skip: Broken test (Disabled until issue 40 is fixed)"); include("skipif.inc"); ?>
55
--FILE--
66
<?php
77

tests/005.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
InterBase: transactions
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php die('skip: Broken test (Disabled until issue 41 is fixed)'); include("skipif.inc"); ?>
55
--FILE--
66
<?php
77

tests/006.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ InterBase: binding (may take a while)
4545
$v_float = rand_number(7);
4646
$v_integer = rand_number(9,0);
4747
$v_numeric = rand_number(4,2);
48-
$v_smallint = rand_number(5) % 32767;
48+
$v_smallint = ((int)rand_number(5)) % 32767;
4949
$v_varchar = rand_str(10000);
5050

5151
ibase_query("insert into test6
@@ -115,7 +115,7 @@ InterBase: binding (may take a while)
115115
$v_float = rand_number(7);
116116
$v_integer = rand_number(9,0);
117117
$v_numeric = rand_number(4,2);
118-
$v_smallint = rand_number(5) % 32767;
118+
$v_smallint = ((int)rand_number(5)) % 32767;
119119
$v_varchar = rand_str(10000);
120120

121121
/* clear table*/

tests/007.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
InterBase: array handling
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php die("skip: Broken test (Disabled until issue 42 is fixed)"); include("skipif.inc"); ?>
55
--FILE--
66
<?php
77

tests/008.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ InterBase: event handling
33
--SKIPIF--
44
<?php
55
if (PHP_OS == "WINNT") echo "skip";
6+
if (PHP_DEBUG) echo "skip: Disabled in debug build until memory leak is fixed (See GitHub issue 45)";
67
include("skipif.inc");
78
?>
89
--FILE--

tests/bug45373.phpt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
--TEST--
22
Bug #45373 (php crash on query with errors in params)
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php
5+
include("skipif.inc");
6+
// See GitHub issue 44
7+
// https://github.com/FirebirdSQL/php-firebird/issues/44
8+
include("skipif-php8-or-newer.inc");
9+
?>
510
--FILE--
611
<?php
712

tests/bug46247.phpt tests/bug46247_001.phpt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
--TEST--
22
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php
5+
include("skipif.inc");
6+
include("skipif-php8-or-newer.inc");
7+
?>
58
--FILE--
69
<?php
710

tests/bug46247_002.phpt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
8+
require("interbase.inc");
9+
10+
$db = ibase_connect($test_base);
11+
12+
ibase_set_event_handler('foo', 1);
13+
ibase_set_event_handler($db, 'foo', 1);
14+
15+
?>
16+
--EXPECTF--
17+
Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d
18+
19+
Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d

tests/bug46247_003.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
include("skipif-php7-or-older.inc");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require("interbase.inc");
12+
13+
$db = ibase_connect($test_base);
14+
15+
function test() { }
16+
17+
ibase_set_event_handler();
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: Uncaught ArgumentCountError: Wrong parameter count for ibase_set_event_handler() in %a

tests/bug46247_004.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
include("skipif-php7-or-older.inc");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require("interbase.inc");
12+
13+
$db = ibase_connect($test_base);
14+
15+
function test() { }
16+
17+
ibase_set_event_handler(NULL, 'test', 1);
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: Uncaught TypeError: ibase_set_event_handler(): supplied argument is not a valid InterBase link resource in %a

tests/bug46543.phpt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
--TEST--
22
Bug #46543 (ibase_trans() memory leaks when using wrong parameters)
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php
5+
include("skipif.inc");
6+
// See GitHub issue 43
7+
// https://github.com/FirebirdSQL/php-firebird/issues/43
8+
include("skipif-php8-or-newer.inc");
9+
?>
510
--FILE--
611
<?php
712

tests/config.inc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
$user = 'SYSDBA';
4+
$password = 'masterkey';
5+
ini_set('ibase.default_user',$user);
6+
ini_set('ibase.default_password',$password);

tests/functions.inc

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
srand(((int)(double)microtime()*1000000));
4+
5+
function out_table($table_name)
6+
{
7+
echo "--- $table_name ---\n";
8+
$res = ibase_query("select * from $table_name");
9+
while ($r = ibase_fetch_row($res)) {
10+
echo join("\t",$r)."\t\n";
11+
}
12+
ibase_free_result($res);
13+
echo "---\n";
14+
}
15+
16+
function out_result($result, $table_name = "")
17+
{
18+
echo "--- $table_name ---\n";
19+
while ($r = ibase_fetch_row($result)) {
20+
echo join("\t",$r)."\t\n";
21+
}
22+
echo "---\n";
23+
}
24+
25+
function out_result_trap_error($result, $table_name = "")
26+
{
27+
echo "--- $table_name ---\n";
28+
while ($r = @ibase_fetch_row($result)) {
29+
echo join("\t",$r)."\t\n";
30+
}
31+
echo "errmsg [" . ibase_errmsg() . "]\n";
32+
echo "---\n";
33+
}
34+
35+
/* M/D/Y H:M:S */
36+
function rand_datetime()
37+
{
38+
return sprintf("%02d/%02d/%4d %02d:%02d:%02d",
39+
rand()%12+1, rand()%28+1, rand()%100+1910,
40+
rand()%24, rand()%60, rand()%60);
41+
}
42+
43+
/* random binary string */
44+
function rand_binstr($max_len)
45+
{
46+
$len = rand() % $max_len;
47+
$s = "";
48+
while($len--) {
49+
$s .= sprintf("%c", rand() % 256);
50+
}
51+
return $s;
52+
}
53+
54+
function rand_str($max_len)
55+
{
56+
$len = rand() % $max_len;
57+
$s = "";
58+
while ($len--) {
59+
$s .= sprintf("%c", rand() % 26 + 65);
60+
}
61+
return $s;
62+
}
63+
64+
function rand_number($len , $prec = -1, $sign = 1)
65+
{
66+
if ($prec == -1) {
67+
$n = substr(rand() . rand(), 0, rand() % $len + 1);
68+
if (strlen($n) < $len) {
69+
$n .= "." . substr(rand(), 0, rand() % ($len - strlen($n)) + 1);
70+
}
71+
} else if ($prec == 0) {
72+
$n = substr(rand() . rand(), 0, rand() % $len + 1);
73+
} else if (($prec - $len) == 0) {
74+
$n = substr(rand() . rand(), 0, 1);
75+
$n .= "." . substr(rand(), 0, $prec);
76+
} else {
77+
$n = substr(rand() . rand(), 0, rand() % ($len - $prec) + 1);
78+
$n .= "." . substr(rand(), 0, $prec);
79+
}
80+
if ($sign && (rand() % 3 == 0)) {
81+
$n = "-" .$n;
82+
}
83+
return $n;
84+
}

0 commit comments

Comments
 (0)