Skip to content

Commit

Permalink
Merge pull request #39 from Jon4t4n/ci
Browse files Browse the repository at this point in the history
Add CI and fix/disable broken tests
  • Loading branch information
Martin Köditz authored Dec 31, 2022
2 parents b6c2883 + 62d5269 commit 0c4bb8a
Show file tree
Hide file tree
Showing 44 changed files with 682 additions and 154 deletions.
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

0 comments on commit 0c4bb8a

Please sign in to comment.