1
0

RootTest.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef RootTest_H
  16. #define RootTest_H
  17. #include "util/CString.h"
  18. #include "util/Js.h"
  19. #include "util/events/libuv/Glock.h"
  20. #include <stdio.h>
  21. #define RootTest_toStr(x) RootTest_toStr2(x)
  22. #define RootTest_toStr2(x) #x
  23. Js({
  24. this.RootTest_mainFunc = RootTest_toStr(main);
  25. this.RootTest_mainName = this.RootTest_mainFunc.replace(/_main$/, '');
  26. })
  27. #define RootTest_mainName Js_or({ return '"' + this.RootTest_mainName + '"' }, "main")
  28. #define RootTest_main Js_or({ return 'RootTest_' + this.RootTest_mainFunc; }, RootTest_main)
  29. int RootTest_main(int argc, char** argv);
  30. int main(int argc, char** argv)
  31. {
  32. Glock_init();
  33. int runIt = 0;
  34. int j = 0;
  35. for (int i = 0; i < argc; i++) {
  36. argv[j] = argv[i];
  37. if (!CString_strcmp("+roottest", argv[i])) {
  38. j--;
  39. runIt = 1;
  40. }
  41. j++;
  42. }
  43. if (runIt) {
  44. return RootTest_main(j,argv);
  45. } else {
  46. fprintf(stderr, "\nRoot test %s disabled, use [%s %s +roottest] to include it\n",
  47. RootTest_mainName,
  48. (argc > 0) ? argv[0] : "",
  49. RootTest_mainName);
  50. }
  51. return 0;
  52. }
  53. #ifdef main
  54. #undef main
  55. #endif
  56. #define main RootTest_main // CHECKFILES_IGNORE
  57. int main(int argc, char** argv);
  58. #endif