File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,3 +147,9 @@ ExternalProject_Add(sleep5_return0
147147 CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} " "-DWAMR_ROOT:STRING=${WAMR_ROOT} "
148148 INSTALL_COMMAND cp sleep5_return0.wasm ${CMAKE_CURRENT_BINARY_DIR} /dist
149149)
150+
151+ ExternalProject_Add (cat
152+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /testing/cat
153+ CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} " "-DWAMR_ROOT:STRING=${WAMR_ROOT} "
154+ INSTALL_COMMAND cp cat.wasm ${CMAKE_CURRENT_BINARY_DIR} /dist
155+ )
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.20.0 )
2+
3+ include (${CMAKE_CURRENT_LIST_DIR} /../../ocre.cmake )
4+
5+ project (cat)
6+
7+ add_executable (cat.wasm main.c )
Original file line number Diff line number Diff line change 1+ /*
2+ * @copyright Copyright © contributors to Project Ocre,
3+ * which has been established as Project Ocre a Series of LF Projects, LLC
4+
5+ * SPDX-License-Identifier: Apache-2.0
6+
7+ */
8+
9+ #include <stdio.h>
10+ #include <string.h>
11+ #include <unistd.h>
12+ #include <errno.h>
13+
14+ #define BUF_SIZE 4096
15+
16+ int main (int argc , char * argv [])
17+ {
18+ int use_stderr = 0 ;
19+ int out_fd = STDOUT_FILENO ;
20+
21+ for (int i = 1 ; i < argc ; i ++ ) {
22+ if (strcmp (argv [i ], "-e" ) == 0 ) {
23+ use_stderr = 1 ;
24+ out_fd = STDERR_FILENO ;
25+ }
26+ }
27+
28+ char buf [BUF_SIZE ];
29+ ssize_t n ;
30+
31+ while ((n = read (STDIN_FILENO , buf , sizeof (buf ))) > 0 ) {
32+ ssize_t written = 0 ;
33+ while (written < n ) {
34+ ssize_t w = write (out_fd , buf + written , n - written );
35+ if (w < 0 ) {
36+ return 1 ;
37+ }
38+ written += w ;
39+ }
40+ }
41+
42+ if (n < 0 ) {
43+ return 1 ;
44+ }
45+
46+ return 0 ;
47+ }
You can’t perform that action at this time.
0 commit comments