Skip to content

Add CI and fix/disable broken tests #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
40b4541
Add GitHub actions
Jon4t4n Dec 27, 2022
5a12a73
Split tests/interbase.inc into 3 files
Jon4t4n Dec 26, 2022
a3c7a0b
Skip tests/004.phpt
Jon4t4n Dec 26, 2022
78bed44
Skip tests/005.phpt
Jon4t4n Dec 26, 2022
0d40b93
Skip tests/007.phpt
Jon4t4n Dec 26, 2022
de5ad0f
Split tests/ibase_param_info_001.phpt into 3 tests
Jon4t4n Dec 27, 2022
97d40fe
Split tests/ibase_num_params_001.phpt into 4 tests
Jon4t4n Dec 27, 2022
8846048
Split tests/ibase_num_fields_001.phpt into 4 tests
Jon4t4n Dec 27, 2022
7017460
Split tests/ibase_free_query_001.phpt into 2 tests
Jon4t4n Dec 27, 2022
9218922
Split tests/ibase_drop_db_001.phpt into 4 tests
Jon4t4n Dec 27, 2022
b56bdff
Split tests/ibase_close_001.phpt into 3 tests
Jon4t4n Dec 27, 2022
933d389
Disable tests/bug46543.phpt in PHP 8
Jon4t4n Dec 27, 2022
185f146
Split tests/bug46247.phpt into 4 tests
Jon4t4n Dec 27, 2022
79898da
Disable tests/bug45373.phpt for PHP 8
Jon4t4n Dec 27, 2022
0248dda
Fix error: implicit conversion from float-string to int loses precision
Jon4t4n Dec 27, 2022
7b30ecf
Remove duplicate ZEND_ARG_INFO for ibase_query
Jon4t4n Dec 27, 2022
8d7d51e
Remove duplicate ZEND_ARG_INFO for ibase_execute
Jon4t4n Dec 27, 2022
7e53f32
Remove duplicate ZEND_ARG_INFO for ibase_trans
Jon4t4n Dec 27, 2022
1c5d420
Fix ZEND_BEGIN_ARG_INFO_EX for ibase_rollback_ret
Jon4t4n Dec 25, 2022
3277cef
Fix ZEND_BEGIN_ARG_INFO_EX for ibase_commit_ret
Jon4t4n Dec 25, 2022
3cdd24f
Fix ZEND_BEGIN_ARG_INFO_EX for ibase_rollback
Jon4t4n Dec 25, 2022
3bcbf0a
Fix ZEND_BEGIN_ARG_INFO_EX for ibase_commit
Jon4t4n Dec 25, 2022
72bfa26
Replace ZEND_ARG_INFO with ZEND_ARG_VARIADIC_INFO for ibase_execute
Jon4t4n Dec 27, 2022
b3f8746
Replace ZEND_ARG_INFO with ZEND_ARG_VARIADIC_INFO for ibase_query
Jon4t4n Dec 27, 2022
c5780ef
Disable tests/008.phpt in debug builds
Jon4t4n Dec 27, 2022
62d5269
Suppress zend_signals warnings
Jon4t4n Dec 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/actions/install-linux/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Install
runs:
using: composite
steps:
- shell: bash
run: |
export DEBIAN_FRONTEND="noninteractive"
sudo apt-get update
sudo apt-get -y -q install firebird-dev firebird3.0 firebird3.0-common firebird3.0-server
FB_ORIGINAL_PASS=`sudo cat /etc/firebird/3.0/SYSDBA.password | grep ISC_PASSWORD | sed -e 's/ISC_PASSWORD="\([^"]*\)".*/\1/'`
gsec -user SYSDBA -password ${FB_ORIGINAL_PASS} -modify sysdba -pw masterkey
sudo service firebird3.0 restart
sudo apt-get -y install pkg-config build-essential autoconf bison re2c libxml2-dev libsqlite3-dev
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
linux:
runs-on: ubuntu-latest
continue-on-error: false
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
steps:
- name: Checkout php-src
uses: actions/checkout@v3
with:
repository: 'php/php-src'
ref: 'PHP-${{ matrix.php }}'
- name: Checkout php-firebird
uses: actions/checkout@v3
with:
path: 'ext/php-firebird'
- name: Install dependencies
uses: ./ext/php-firebird/.github/actions/install-linux
- name: Build
run: |
./buildconf --force
./configure --disable-all --with-interbase
make -j$(/usr/bin/nproc)
- name: Test
run: sudo make test TESTS='ext/php-firebird --show-diff'
linux-debug:
runs-on: ubuntu-latest
continue-on-error: false
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
steps:
- name: Checkout php-src
uses: actions/checkout@v3
with:
repository: 'php/php-src'
ref: 'PHP-${{ matrix.php }}'
- name: Checkout php-firebird
uses: actions/checkout@v3
with:
path: 'ext/php-firebird'
- name: Install dependencies
uses: ./ext/php-firebird/.github/actions/install-linux
- name: Build
run: |
./buildconf --force
./configure --disable-all --with-interbase --enable-debug
make -j$(/usr/bin/nproc)
- name: Test
run: sudo make test TESTS='ext/php-firebird --show-diff'

22 changes: 11 additions & 11 deletions interbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_drop_db, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_trans, 0, 0, 0)
ZEND_ARG_INFO(0, trans_args)
ZEND_ARG_INFO(0, link_identifier)
ZEND_ARG_INFO(0, trans_args)
ZEND_ARG_INFO(0, link_identifier)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit, 0, 0, 1)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit, 0, 0, 0)
ZEND_ARG_INFO(0, link_identifier)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback, 0, 0, 1)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback, 0, 0, 0)
ZEND_ARG_INFO(0, link_identifier)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit_ret, 0, 0, 1)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_commit_ret, 0, 0, 0)
ZEND_ARG_INFO(0, link_identifier)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback_ret, 0, 0, 1)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_rollback_ret, 0, 0, 0)
ZEND_ARG_INFO(0, link_identifier)
ZEND_END_ARG_INFO()

Expand Down Expand Up @@ -158,11 +156,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_blob_import, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_query, 0, 0, 0)
ZEND_ARG_INFO(0, link_identifier)
ZEND_ARG_INFO(0, link_identifier)
ZEND_ARG_INFO(0, query)
ZEND_ARG_INFO(0, bind_arg)
ZEND_ARG_INFO(0, bind_arg)
ZEND_ARG_VARIADIC_INFO(0, bind_arg)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_affected_rows, 0, 0, 0)
Expand Down Expand Up @@ -206,8 +202,7 @@ ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_execute, 0, 0, 1)
ZEND_ARG_INFO(0, query)
ZEND_ARG_INFO(0, bind_arg)
ZEND_ARG_INFO(0, bind_arg)
ZEND_ARG_VARIADIC_INFO(0, bind_arg)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ibase_free_query, 0, 0, 1)
Expand Down Expand Up @@ -764,6 +759,11 @@ PHP_MINIT_FUNCTION(ibase)
php_ibase_events_minit(INIT_FUNC_ARGS_PASSTHRU);
php_ibase_service_minit(INIT_FUNC_ARGS_PASSTHRU);

#ifdef ZEND_SIGNALS
// firebird replaces some signals at runtime, suppress warnings.
SIGG(check) = 0;
#endif

return SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ InterBase: misc sql types (may take a while)
$v_double = rand_number(18);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_smallint = rand_number(5) % 32767;
$v_smallint = ((int)rand_number(5)) % 32767;
$v_varchar = rand_str(10000);

ibase_query(
Expand Down
2 changes: 1 addition & 1 deletion tests/004.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
InterBase: BLOB test
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php die("skip: Broken test (Disabled until issue 40 is fixed)"); include("skipif.inc"); ?>
--FILE--
<?php

Expand Down
2 changes: 1 addition & 1 deletion tests/005.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
InterBase: transactions
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php die('skip: Broken test (Disabled until issue 41 is fixed)'); include("skipif.inc"); ?>
--FILE--
<?php

Expand Down
4 changes: 2 additions & 2 deletions tests/006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ InterBase: binding (may take a while)
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_numeric = rand_number(4,2);
$v_smallint = rand_number(5) % 32767;
$v_smallint = ((int)rand_number(5)) % 32767;
$v_varchar = rand_str(10000);

ibase_query("insert into test6
Expand Down Expand Up @@ -115,7 +115,7 @@ InterBase: binding (may take a while)
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_numeric = rand_number(4,2);
$v_smallint = rand_number(5) % 32767;
$v_smallint = ((int)rand_number(5)) % 32767;
$v_varchar = rand_str(10000);

/* clear table*/
Expand Down
2 changes: 1 addition & 1 deletion tests/007.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
InterBase: array handling
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php die("skip: Broken test (Disabled until issue 42 is fixed)"); include("skipif.inc"); ?>
--FILE--
<?php

Expand Down
1 change: 1 addition & 0 deletions tests/008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ InterBase: event handling
--SKIPIF--
<?php
if (PHP_OS == "WINNT") echo "skip";
if (PHP_DEBUG) echo "skip: Disabled in debug build until memory leak is fixed (See GitHub issue 45)";
include("skipif.inc");
?>
--FILE--
Expand Down
7 changes: 6 additions & 1 deletion tests/bug45373.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
--TEST--
Bug #45373 (php crash on query with errors in params)
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php
include("skipif.inc");
// See GitHub issue 44
// https://github.com/FirebirdSQL/php-firebird/issues/44
include("skipif-php8-or-newer.inc");
?>
--FILE--
<?php

Expand Down
5 changes: 4 additions & 1 deletion tests/bug46247.phpt → tests/bug46247_001.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
--TEST--
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php
include("skipif.inc");
include("skipif-php8-or-newer.inc");
?>
--FILE--
<?php

Expand Down
19 changes: 19 additions & 0 deletions tests/bug46247_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php

require("interbase.inc");

$db = ibase_connect($test_base);

ibase_set_event_handler('foo', 1);
ibase_set_event_handler($db, 'foo', 1);

?>
--EXPECTF--
Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d

Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d
21 changes: 21 additions & 0 deletions tests/bug46247_003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
--SKIPIF--
<?php
include("skipif.inc");
include("skipif-php7-or-older.inc");
?>
--FILE--
<?php

require("interbase.inc");

$db = ibase_connect($test_base);

function test() { }

ibase_set_event_handler();

?>
--EXPECTF--
Fatal error: Uncaught ArgumentCountError: Wrong parameter count for ibase_set_event_handler() in %a
21 changes: 21 additions & 0 deletions tests/bug46247_004.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
--SKIPIF--
<?php
include("skipif.inc");
include("skipif-php7-or-older.inc");
?>
--FILE--
<?php

require("interbase.inc");

$db = ibase_connect($test_base);

function test() { }

ibase_set_event_handler(NULL, 'test', 1);

?>
--EXPECTF--
Fatal error: Uncaught TypeError: ibase_set_event_handler(): supplied argument is not a valid InterBase link resource in %a
7 changes: 6 additions & 1 deletion tests/bug46543.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
--TEST--
Bug #46543 (ibase_trans() memory leaks when using wrong parameters)
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php
include("skipif.inc");
// See GitHub issue 43
// https://github.com/FirebirdSQL/php-firebird/issues/43
include("skipif-php8-or-newer.inc");
?>
--FILE--
<?php

Expand Down
6 changes: 6 additions & 0 deletions tests/config.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$user = 'SYSDBA';
$password = 'masterkey';
ini_set('ibase.default_user',$user);
ini_set('ibase.default_password',$password);
84 changes: 84 additions & 0 deletions tests/functions.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

srand(((int)(double)microtime()*1000000));

function out_table($table_name)
{
echo "--- $table_name ---\n";
$res = ibase_query("select * from $table_name");
while ($r = ibase_fetch_row($res)) {
echo join("\t",$r)."\t\n";
}
ibase_free_result($res);
echo "---\n";
}

function out_result($result, $table_name = "")
{
echo "--- $table_name ---\n";
while ($r = ibase_fetch_row($result)) {
echo join("\t",$r)."\t\n";
}
echo "---\n";
}

function out_result_trap_error($result, $table_name = "")
{
echo "--- $table_name ---\n";
while ($r = @ibase_fetch_row($result)) {
echo join("\t",$r)."\t\n";
}
echo "errmsg [" . ibase_errmsg() . "]\n";
echo "---\n";
}

/* M/D/Y H:M:S */
function rand_datetime()
{
return sprintf("%02d/%02d/%4d %02d:%02d:%02d",
rand()%12+1, rand()%28+1, rand()%100+1910,
rand()%24, rand()%60, rand()%60);
}

/* random binary string */
function rand_binstr($max_len)
{
$len = rand() % $max_len;
$s = "";
while($len--) {
$s .= sprintf("%c", rand() % 256);
}
return $s;
}

function rand_str($max_len)
{
$len = rand() % $max_len;
$s = "";
while ($len--) {
$s .= sprintf("%c", rand() % 26 + 65);
}
return $s;
}

function rand_number($len , $prec = -1, $sign = 1)
{
if ($prec == -1) {
$n = substr(rand() . rand(), 0, rand() % $len + 1);
if (strlen($n) < $len) {
$n .= "." . substr(rand(), 0, rand() % ($len - strlen($n)) + 1);
}
} else if ($prec == 0) {
$n = substr(rand() . rand(), 0, rand() % $len + 1);
} else if (($prec - $len) == 0) {
$n = substr(rand() . rand(), 0, 1);
$n .= "." . substr(rand(), 0, $prec);
} else {
$n = substr(rand() . rand(), 0, rand() % ($len - $prec) + 1);
$n .= "." . substr(rand(), 0, $prec);
}
if ($sign && (rand() % 3 == 0)) {
$n = "-" .$n;
}
return $n;
}
Loading