|
|
@@ -0,0 +1,60 @@
|
|
|
+#include <zivuos/process.h>
|
|
|
+#include <zivuos/porttypes.h>
|
|
|
+#include <zivuos/worker.h>
|
|
|
+#include <zivuos/pipe.h>
|
|
|
+
|
|
|
+#include <stdio.h>
|
|
|
+
|
|
|
+int main() {
|
|
|
+ puts("Creating pipe...");
|
|
|
+ zv_pipe_t *pipe = zv_pipe_create();
|
|
|
+
|
|
|
+ if (pipe == NULL) {
|
|
|
+ puts("Can not create pipe!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ puts("Pipe was created.");
|
|
|
+
|
|
|
+ if (zv_pipe_is_changed(pipe)) {
|
|
|
+ puts("Pipe created as changed. FAIL.");
|
|
|
+ } else {
|
|
|
+ puts("Pipe created sucess!");
|
|
|
+ }
|
|
|
+
|
|
|
+ zv_pipe_write_number(pipe, 100);
|
|
|
+
|
|
|
+ if (zv_pipe_is_changed(pipe)) {
|
|
|
+ puts("Pipe write success!");
|
|
|
+ } else {
|
|
|
+ puts("Pipe write fail. Not mark as changed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (zv_pipe_read_number(pipe) == 100) {
|
|
|
+ puts("Pipe read success!");
|
|
|
+ } else {
|
|
|
+ puts("Pipe return ivalid value.");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!zv_pipe_is_changed(pipe)) {
|
|
|
+ puts("Pipe read mark success!");
|
|
|
+ } else {
|
|
|
+ puts("Pipe read fail. Not unmarked as changed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ int array[] = {0x01, 0x02};
|
|
|
+
|
|
|
+ zv_pipe_write_content(pipe, (void *) array);
|
|
|
+
|
|
|
+ if (zv_pipe_is_changed(pipe)) {
|
|
|
+ if (*((int *) zv_pipe_read_content(pipe)) == array[0]) {
|
|
|
+ puts("Pipe as pointer work propertly!");
|
|
|
+ } else {
|
|
|
+ puts("Pipe marked as changed, but pointer not correct.");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ puts("Pipe not marked as changed from pointer storage.");
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|