!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/cpanel/ea-ruby27/src/passenger-release-6.0.23/test/cxx/   drwxr-xr-x
Free 289.41 GB of 429.69 GB (67.35%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     MessagePassingTest.cpp (2.1 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#include <TestSupport.h>
#include <boost/bind/bind.hpp>
#include <Utils/MessagePassing.h>
#include <Utils/Timer.h>

using namespace Passenger;
using namespace std;

namespace tut {
    struct MessagePassingTest: public TestBase {
        MessageBoxPtr box;

        MessagePassingTest() {
            box = boost::make_shared<MessageBox>();
        }

        void sendMessagesLater() {
            syscalls::usleep(20000);
            box->send("hi");
            syscalls::usleep(20000);
            box->send("ho");
        }
    };

    DEFINE_TEST_GROUP(MessagePassingTest);

    TEST_METHOD(1) {
        // Sending and receiving 1 message.
        box->send("hi");
        ensure_equals(box->size(), 1u);
        ensure_equals(box->recv("hi")->name, "hi");
        ensure_equals(box->size(), 0u);
    }

    TEST_METHOD(2) {
        // Sending and receiving multiple messages out of order.
        box->send("ho");
        box->send("hi");
        box->send("ha");
        ensure_equals(box->size(), 3u);
        ensure_equals(box->recv("hi")->name, "hi");
        ensure_equals(box->size(), 2u);
        ensure_equals(box->recv("ho")->name, "ho");
        ensure_equals(box->size(), 1u);
        ensure_equals(box->recv("ha")->name, "ha");
        ensure_equals(box->size(), 0u);
    }

    TEST_METHOD(3) {
        // Receive with zero timeout.
        unsigned long long timeoutUSec = 0;
        Timer<> timer;
        ensure_equals(box->recv("hi", &timeoutUSec), MessagePtr());
        ensure(timer.elapsed() < 10);
        ensure_equals(timeoutUSec, 0ull);
    }

    TEST_METHOD(4) {
        // Receive with non-zero timeout.
        unsigned long long timeoutUSec = 20000;
        Timer<> timer;
        ensure_equals(box->recv("hi", &timeoutUSec), MessagePtr());
        ensure("(1)", timer.elapsed() >= 19);
        ensure("(2)", timer.elapsed() < 95);
        ensure("(3)", timeoutUSec <= 2000ull);
    }

    TEST_METHOD(5) {
        // Test waiting with timeout.
        TempThread thr(boost::bind(&MessagePassingTest::sendMessagesLater, this));
        unsigned long long timeoutUSec = 200000;
        Timer<> timer;
        ensure_equals("(1)", box->recv("ho", &timeoutUSec)->name, "ho");
        ensure("(2)", timer.elapsed() >= 39);
        ensure("(3)", timer.elapsed() < 95);
        ensure_equals("(4)", box->size(), 1u);
        ensure_equals("(5)", box->recv("hi")->name, "hi");
        ensure_equals("(6)", box->size(), 0u);
        ensure("(7)", timeoutUSec >= 100000);
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0969 ]--