test_gnunet_prefix.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. This file is part of GNUnet
  3. (C) 2011, 2014 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @file contrib/test_gnunet_prefix.c
  19. * @brief test if environment variable GNUNET_PREFIX is set so that
  20. * we have a chance to run tests
  21. * @author Christian Grothoff
  22. */
  23. #include "platform.h"
  24. int
  25. main (int argc,
  26. char **argv)
  27. {
  28. const char *basename;
  29. const char *dirname;
  30. basename = getenv ("GNUNET_PREFIX");
  31. if (NULL == basename)
  32. {
  33. fprintf (stderr,
  34. _("Environment variable GNUNET_PREFIX not set\n"));
  35. fprintf (stderr,
  36. _("Testcases will not work!\n"));
  37. return 1;
  38. }
  39. dirname = DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR "config.d";
  40. {
  41. char tmp[strlen (basename) + strlen (dirname) + 1];
  42. sprintf (tmp, "%s%s", basename, dirname);
  43. if (0 != access (tmp, R_OK))
  44. {
  45. fprintf (stderr,
  46. _("Failed to access `%s': %s\n"),
  47. tmp,
  48. STRERROR (errno));
  49. fprintf (stderr,
  50. _("Check that you did run `make install' and that GNUNET_PREFIX='%s' is the correct prefix.\n"),
  51. basename);
  52. fprintf (stderr,
  53. _("Testcases will not work!\n"));
  54. return 2;
  55. }
  56. }
  57. return 0;
  58. }