testing.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <zivuos/process.h>
  2. #include <zivuos/porttypes.h>
  3. #include <zivuos/worker.h>
  4. #include <zivuos/pipe.h>
  5. #include <stdio.h>
  6. int main() {
  7. puts("Creating pipe...");
  8. zv_pipe_t *pipe = zv_pipe_create();
  9. if (pipe == NULL) {
  10. puts("Can not create pipe!");
  11. return -1;
  12. }
  13. puts("Pipe was created.");
  14. if (zv_pipe_is_changed(pipe)) {
  15. puts("Pipe created as changed. FAIL.");
  16. } else {
  17. puts("Pipe created sucess!");
  18. }
  19. zv_pipe_write_number(pipe, 100);
  20. if (zv_pipe_is_changed(pipe)) {
  21. puts("Pipe write success!");
  22. } else {
  23. puts("Pipe write fail. Not mark as changed.");
  24. }
  25. if (zv_pipe_read_number(pipe) == 100) {
  26. puts("Pipe read success!");
  27. } else {
  28. puts("Pipe return ivalid value.");
  29. }
  30. if (!zv_pipe_is_changed(pipe)) {
  31. puts("Pipe read mark success!");
  32. } else {
  33. puts("Pipe read fail. Not unmarked as changed.");
  34. }
  35. int array[] = {0x01, 0x02};
  36. zv_pipe_write_content(pipe, (void *) array);
  37. if (zv_pipe_is_changed(pipe)) {
  38. if (*((int *) zv_pipe_read_content(pipe)) == array[0]) {
  39. puts("Pipe as pointer work propertly!");
  40. } else {
  41. puts("Pipe marked as changed, but pointer not correct.");
  42. }
  43. } else {
  44. puts("Pipe not marked as changed from pointer storage.");
  45. }
  46. return 0;
  47. }