We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
commit  4becb67e448055fb31a89cb4979a8356c54f81c8
tree    2fdfe6b0b8a9fdda3db65862772278e9bca92d97
parent  92ed565be331bcda7548a4d14d8d495d9c316b80
passenger / test / SpawnManagerTest.cpp
100644 32 lines (26 sloc) 0.899 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "tut.h"
#include "SpawnManager.h"
#include <cstring>
#include <unistd.h>
 
using namespace Passenger;
 
namespace tut {
  struct SpawnManagerTest {
  };
 
  DEFINE_TEST_GROUP(SpawnManagerTest);
 
  TEST_METHOD(1) {
    // Spawning an application should return a valid Application object.
    SpawnManager manager("support/spawn_server_mock.rb");
    ApplicationPtr app(manager.spawn("."));
    char buf[5];
 
    ensure_equals("The Application object's PID is the same as the one specified by the mock",
      app->getPid(), 1234);
    ensure_equals("Application.getWriter() is a valid, writable file descriptor",
      write(app->getWriter(), "hello", 5),
      5);
    ensure_equals("Application.getReader() is a valid, readable file descriptor",
      read(app->getReader(), buf, 5),
      5);
    ensure("The two channels are connected with each other, as specified by the mock object",
      memcmp(buf, "hello", 5) == 0);
  }
}