-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,605 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extension=ssh2.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
shopt -s nullglob | ||
export LC_ALL=C | ||
|
||
for i in /tmp/core_*.*; do | ||
if [ -f "$i" -a "$(file "$i" | grep -o 'core file')" ]; then | ||
gdb -q $(phpenv which php) "$i" <<EOF | ||
set pagination 0 | ||
backtrace full | ||
info registers | ||
x/16i \$pc | ||
thread apply all backtrace | ||
quit | ||
EOF | ||
fi | ||
done | ||
|
||
$(phpenv which php) -m | ||
$(phpenv which php) -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" | ||
|
||
install_ssh2() { | ||
sudo apt-get install -y -qq libssh2-1-dev libssh2-1 | ||
|
||
git clone -q https://github.com/php/pecl-networking-ssh2 -b php5 /tmp/ssh2 | ||
cd /tmp/ssh2 | ||
|
||
phpize &> /dev/null | ||
./configure &> /dev/null | ||
|
||
make --silent -j4 &> /dev/null | ||
make --silent install | ||
|
||
if [ -z $(php -m | grep ssh2) ]; then | ||
phpenv config-add "${TRAVIS_BUILD_DIR}/build-ci/ini/ssh2.ini" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" | ||
|
||
install_ssh2() { | ||
sudo apt-get install -y -qq libssh2-1-dev libssh2-1 | ||
|
||
git clone -q https://github.com/php/pecl-networking-ssh2 -b master /tmp/ssh2 | ||
cd /tmp/ssh2 | ||
|
||
phpize &> /dev/null | ||
./configure &> /dev/null | ||
|
||
make --silent -j4 &> /dev/null | ||
make --silent install | ||
|
||
if [ -z $(php -m | grep ssh2) ]; then | ||
phpenv config-add "${TRAVIS_BUILD_DIR}/build-ci/ini/ssh2.ini" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" | ||
|
||
pecl channel-update pecl.php.net || true | ||
echo `whoami`":1234" | sudo chpasswd | ||
|
||
enable_extension() { | ||
if [ -z $(php -m | grep "${1}") ] && [ -f "${TRAVIS_BUILD_DIR}/build-ci/ini/${1}.ini" ]; then | ||
phpenv config-add "${TRAVIS_BUILD_DIR}/build-ci/ini/${1}.ini" | ||
fi | ||
} | ||
|
||
install_extension() { | ||
INSTALLED=$(pecl list "${1}" | grep 'not installed') | ||
|
||
if [ -z "${INSTALLED}" ]; then | ||
printf "\n" | pecl upgrade "${1}" &> /dev/null | ||
else | ||
printf "\n" | pecl install "${1}" &> /dev/null | ||
fi | ||
|
||
enable_extension "${1}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" | ||
|
||
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_common.sh | ||
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_5.sh | ||
|
||
install_ssh2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" | ||
|
||
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_common.sh | ||
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_7.sh | ||
|
||
install_ssh2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This source file is subject to the MIT License that is bundled | ||
# with this package in the MIT license. | ||
|
||
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" | ||
|
||
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_common.sh | ||
source ${TRAVIS_BUILD_DIR}/build-ci/install_php_7.sh | ||
|
||
install_ssh2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Dazzle\SSH\Test; | ||
|
||
class Callback | ||
{ | ||
public function __invoke() | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?php | ||
|
||
namespace Dazzle\SSH\Test; | ||
|
||
use Dazzle\Loop\Model\SelectLoop; | ||
use Dazzle\Loop\Loop; | ||
use Dazzle\Loop\LoopExtendedInterface; | ||
use Dazzle\Loop\LoopInterface; | ||
use Dazzle\SSH\Test\_Simulation\Event; | ||
use Dazzle\SSH\Test\_Simulation\Simulation; | ||
use Exception; | ||
|
||
class TModule extends TUnit | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const MSG_EVENT_NAME_ASSERTION_FAILED = 'Expected event name mismatch on %s event.'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
const MSG_EVENT_DATA_ASSERTION_FAILED = 'Expected event data mismatch on %s event.'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
const MSG_EVENT_GET_ASSERTION_FAILED = "Expected event count mismatch after %s events.\nExpected event %s, got event %s."; | ||
|
||
/** | ||
* @var LoopExtendedInterface | ||
*/ | ||
private $loop; | ||
|
||
/** | ||
* @var Simulation | ||
*/ | ||
private $sim; | ||
|
||
/** | ||
* | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->loop = null; | ||
$this->sim = null; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function tearDown() | ||
{ | ||
unset($this->sim); | ||
unset($this->loop); | ||
} | ||
|
||
/** | ||
* @return LoopInterface|null | ||
*/ | ||
public function getLoop() | ||
{ | ||
return $this->loop; | ||
} | ||
|
||
/** | ||
* Run test scenario as simulation. | ||
* | ||
* @param callable(Simulation) $scenario | ||
* @return TModule | ||
*/ | ||
public function simulate(callable $scenario) | ||
{ | ||
try | ||
{ | ||
$this->loop = new Loop(new SelectLoop); | ||
$this->loop->erase(true); | ||
|
||
$this->sim = new Simulation($this->loop); | ||
$this->sim->setScenario($scenario); | ||
$this->sim->begin(); | ||
} | ||
catch (Exception $ex) | ||
{ | ||
$this->fail($ex->getMessage()); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param $events | ||
* @param int $flags | ||
* @return TModule | ||
*/ | ||
public function expect($events, $flags = Simulation::EVENTS_COMPARE_IN_ORDER) | ||
{ | ||
$expectedEvents = []; | ||
|
||
foreach ($events as $event) | ||
{ | ||
$data = isset($event[1]) ? $event[1] : []; | ||
$expectedEvents[] = new Event($event[0], $data); | ||
} | ||
|
||
$this->assertEvents( | ||
$this->sim->getExpectations(), | ||
$expectedEvents, | ||
$flags | ||
); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param Event[] $actualEvents | ||
* @param Event[] $expectedEvents | ||
* @param int $flags | ||
*/ | ||
public function assertEvents($actualEvents = [], $expectedEvents = [], $flags = Simulation::EVENTS_COMPARE_IN_ORDER) | ||
{ | ||
$count = max(count($actualEvents), count($expectedEvents)); | ||
|
||
if ($flags === Simulation::EVENTS_COMPARE_RANDOMLY) | ||
{ | ||
sort($actualEvents); | ||
sort($expectedEvents); | ||
} | ||
|
||
for ($i=0; $i<$count; $i++) | ||
{ | ||
if (!isset($actualEvents[$i])) | ||
{ | ||
$this->fail( | ||
sprintf(self::MSG_EVENT_GET_ASSERTION_FAILED, $i, $expectedEvents[$i]->name(), 'null') | ||
); | ||
} | ||
else if (!isset($expectedEvents[$i])) | ||
{ | ||
$this->fail( | ||
sprintf(self::MSG_EVENT_GET_ASSERTION_FAILED, $i, 'null', $actualEvents[$i]->name()) | ||
); | ||
} | ||
|
||
$actualEvent = $actualEvents[$i]; | ||
$expectedEvent = $expectedEvents[$i]; | ||
|
||
$this->assertSame( | ||
$expectedEvent->name(), | ||
$actualEvent->name(), | ||
sprintf(self::MSG_EVENT_NAME_ASSERTION_FAILED, $i) | ||
); | ||
$this->assertSame( | ||
$expectedEvent->data(), | ||
$actualEvent->data(), | ||
sprintf(self::MSG_EVENT_DATA_ASSERTION_FAILED, $i) | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.