RootTest.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef RootTest_H
  16. #define RootTest_H
  17. #include "util/CString.h"
  18. #include <stdio.h>
  19. #define RootTest_toStr(x) RootTest_toStr2(x)
  20. #define RootTest_toStr2(x) #x
  21. <?js file.RootTest_mainFunc = RootTest_toStr(main) ?>
  22. #define RootTest_main <?js return 'RootTest_'+file.RootTest_mainFunc; ?>
  23. int RootTest_main(int argc, char** argv);
  24. int main(int argc, char** argv)
  25. {
  26. int runIt = 0;
  27. int j = 0;
  28. for (int i = 0; i < argc; i++) {
  29. argv[j] = argv[i];
  30. if (!CString_strcmp("+roottest", argv[i])) {
  31. j--;
  32. runIt = 1;
  33. }
  34. j++;
  35. }
  36. if (runIt) {
  37. return RootTest_main(j,argv);
  38. } else {
  39. printf("Root test %s disabled, use [%s +roottest] to include it\n", RootTest_toStr(main),
  40. (argc > 0) ? argv[0] : "");
  41. }
  42. return 0;
  43. }
  44. #ifdef main
  45. #undef main
  46. #endif
  47. #define main RootTest_main // CHECKFILES_IGNORE
  48. int main(int argc, char** argv);
  49. #endif