Sha256: 23e6e80d46ea10bbeddd8d05c0b2c660138c1211e28e7b816315d941fd4746f7

Contents?: true

Size: 718 Bytes

Versions: 66

Compression:

Stored size: 718 Bytes

Contents

#include "../tut/tut.h"
#include <boost/bind.hpp>
#include <oxt/thread.hpp>
#include <oxt/system_calls.hpp>
#include <unistd.h>
#include <ctime>

using namespace oxt;
using namespace std;
using namespace boost;

namespace tut {
	struct syscall_interruption_test {
	};
	
	DEFINE_TEST_GROUP(syscall_interruption_test);
	
	struct SleepFunction {
		void operator()() {
			syscalls::usleep(6000000);
		}
	};
	
	TEST_METHOD(1) {
		// System call interruption works.
		SleepFunction s;
		oxt::thread thr(s);
		usleep(20000);
		
		time_t begin, end, time_spent_in_thread;
		begin = time(NULL);
		thr.interrupt_and_join();
		end = time(NULL);
		time_spent_in_thread = end - begin;
		
		ensure(time_spent_in_thread <= 2);
	}
}

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
passenger-4.0.27 test/oxt/syscall_interruption_test.cpp
passenger-4.0.26 test/oxt/syscall_interruption_test.cpp
passenger-4.0.25 test/oxt/syscall_interruption_test.cpp
passenger-4.0.24 test/oxt/syscall_interruption_test.cpp
passenger-4.0.23 test/oxt/syscall_interruption_test.cpp
passenger-4.0.21 test/oxt/syscall_interruption_test.cpp
passenger-4.0.20 test/oxt/syscall_interruption_test.cpp
passenger-4.0.19 test/oxt/syscall_interruption_test.cpp
passenger-4.0.18 test/oxt/syscall_interruption_test.cpp
passenger-4.0.17 test/oxt/syscall_interruption_test.cpp
passenger-4.0.16 test/oxt/syscall_interruption_test.cpp
passenger-4.0.14 test/oxt/syscall_interruption_test.cpp
passenger-4.0.13 test/oxt/syscall_interruption_test.cpp
passenger-4.0.10 test/oxt/syscall_interruption_test.cpp
passenger-4.0.8 test/oxt/syscall_interruption_test.cpp
passenger-4.0.7 test/oxt/syscall_interruption_test.cpp
passenger-4.0.6 test/oxt/syscall_interruption_test.cpp
passenger-4.0.5 test/oxt/syscall_interruption_test.cpp
passenger-4.0.4 test/oxt/syscall_interruption_test.cpp
passenger-4.0.3 test/oxt/syscall_interruption_test.cpp