1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Original author: Paul McCullagh
20
* Continued development: Barry Leslie
42
void *tst_test_thread_run()
45
CSL.log(self, CSLog::Protocol, "Hello from a thread!\n");
49
void *tst_fail_thread_run()
53
CSThread::sleep(1000);
54
CSException::throwAssertion(CS_CONTEXT, "Fail now!");
59
void *tst_kill_thread_run()
63
CSThread::sleep(1000000);
68
void *tst_telnet_thread_run()
70
CSSocket *listener = NULL;
71
CSSocket *telnet = NULL;
72
CSOutputStream *out = NULL;
73
CSInputStream *in = NULL;
74
CSStringBuffer *sb = NULL;
78
listener = CSSocket::newSocket();
79
telnet = CSSocket::newSocket();
81
CSL.log(self, CSLog::Protocol, "Waiting for telnet on port 8080...\n");
82
listener->publish(NULL, 8080);
83
telnet->open(listener);
84
out = telnet->getOutputStream();
85
out = CSBufferedOutputStream::newStream(out);
86
in = telnet->getInputStream();
87
in = CSBufferedInputStream::newStream(in);
88
out->printLine("Hallo!, enter quit to exit!");
91
out->printLine(sb->getCString());
92
if (strcmp(sb->getCString(), "quit") == 0)
115
void CSTest::runAll()
123
new_(obj, CSRefObject);
128
CSString *s = CSString::newString("This is a log test\nThe 2nd line\n");
129
CSL.log(self, CSLog::Protocol, s);
134
t = CSThread::newThread(CSString::newString("test_thread"), tst_test_thread_run, NULL);
138
t = CSThread::newThread(CSString::newString("fail_thread"), tst_fail_thread_run, NULL);
143
t = CSThread::newThread(CSString::newString("kill_thread"), tst_kill_thread_run, NULL);
145
CSThread::sleep(1000);
146
t->signal(SIGTERM); // Kill the thread
150
t = CSThread::newThread(CSString::newString("telnet_thread"), tst_telnet_thread_run, NULL);