summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuodong Xu <guodong.xu@linaro.org>2012-08-02 16:47:21 +0800
committerGuodong Xu <guodong.xu@linaro.org>2012-08-02 16:47:21 +0800
commit1083863bc2bcf8460ca7131577423430c6e91d14 (patch)
tree54b587a25fd1c23e8360f1015291dd4396d142aa
parent2efcb53e7b624a44450a4a50e62e4bd9ffa449ae (diff)
Temp solution, to enable output of STM messages through STM dummy device to /dev/ttyprintk
-rw-r--r--main.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/main.c b/main.c
index b8d91f5..de7cf17 100644
--- a/main.c
+++ b/main.c
@@ -12,10 +12,12 @@
#include <dirent.h>
#include <pthread.h>
#include <time.h>
+#include <unistd.h>
#include "test_commands.h"
#include "param_array.h"
#include "async_veri.h"
+#include "redirect_ttyprintk.h"
/* global const */
#ifdef LOCAL_TEST_STUB
@@ -1324,6 +1326,18 @@ int stm_commands_from_file(FILE *fp_input)
int main(int argc, char** argv)
{
int ret = -1;
+ int fd_ttyprintk = -1;
+
+ /* TODO: call this only if the underlining STM device is dummy.
+ */
+ /* Attach N_TRACESINK to /dev/ttyprink
+ */
+ fd_ttyprintk = redirect_ttyprintk();
+ if (fd_ttyprintk == -1) {
+ printf("Error: failed to open and redirect /dev/ttyprintk.\n");
+ return -1;
+ }
+ TDBG("Succeed to attach N_TRACESINK to /dev/ttyprintk.\n");
/* create asynchronous verification thread */
ret = pthread_create(&thread_async_id, NULL, \
@@ -1364,6 +1378,10 @@ int main(int argc, char** argv)
TDBG("In line %d, %s()\n", __LINE__, __FUNCTION__);
+ /* close ttyprintk */
+ if (fd_ttyprintk != -1)
+ close(fd_ttyprintk);
+
/* return */
return 0;
}