내 서버에 부스트 유닛 테스트를 쓰려고합니다. 내 서버를 시작하고 싶습니다. - start()는 스레드에서 서버를 시작합니다. 클라이언트를 열고 연결 한 다음 파일을 다운로드하려고합니다.부스트 유닛 테스트에서 파이프 사용
나는이 이런 식으로 일을 해요 :
tftp_server* my_test_server;
BOOST_AUTO_TEST_SUITE (tftptest) // name of the test suite is tftptest
BOOST_AUTO_TEST_CASE (test1)
{
my_test_server = new tftp_server(69);
my_test_server->start();
FILE *in;
char buff[512];
if(!(in = popen("tftp", "w"))){
exit(1);
}
fputs ("connect xx.xx.xx.xx\n", in);
fputs ("mode binary\n", in);
fputs ("mode\n", in);
fputs ("get truc.txt\n", in);
while(fgets(buff, sizeof(buff), in)!=NULL)
printf("%s", buff);
sleep(10);
BOOST_CHECK(true);
}
1) 서버를 생성 및 실행,
2) 시스템 TFTP 클라이언트 (나는 OSX에있어) 사용을
3) 10 초 기다림.
작동하지 않습니다. 테스트가 완료된 후에 만 클라이언트를 실행합니다.
Running 1 test case...
Server started on port 69
Server running.
*** No errors detected
$ Using octet mode to transfer files.
Transfer timed out.
어떤 문제로 내 문제를 해결할 수 있습니까?
감사합니다.
편집
void tftp_server::start()
{
LOG_INFO("Server running.", 0);
boost::thread bt(boost::bind(&boost::asio::io_service::run, &_io_service));
}
고객의 위치는 어디입니까? 어떻게 스레드를 사용합니까? 'my_test_server-> start();'스레드를 시작합니까? – Theolodis
예, 스레드를 시작합니다 (구현에 대한 내 질문을 업데이트했습니다). 클라이언트는 OSX 시스템 클라이언트입니다 (보통 터미널에서 사용합니다). –
좋습니다. 클라이언트를 어디에서 시작합니까? 나는 당신이 같은 테스트 방법으로 클라이언트를 시작했다면 작동 할 것이라고 말하고 싶다. – Theolodis