test_gnunet_prefix.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2011, 2014 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your 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. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file contrib/test_gnunet_prefix.c
  18. * @brief test if environment variable GNUNET_PREFIX is set so that
  19. * we have a chance to run tests
  20. * @author Christian Grothoff
  21. */
  22. #include "platform.h"
  23. int
  24. main (int argc, char **argv)
  25. {
  26. const char *basename;
  27. const char *dirname;
  28. basename = getenv ("GNUNET_PREFIX");
  29. if (NULL == basename)
  30. {
  31. fprintf (stderr, _ ("Environment variable GNUNET_PREFIX not set\n"));
  32. fprintf (stderr, _ ("Testcases will not work!\n"));
  33. return 1;
  34. }
  35. dirname = DIR_SEPARATOR_STR ".." DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
  36. "gnunet" DIR_SEPARATOR_STR "config.d";
  37. {
  38. char tmp[strlen (basename) + strlen (dirname) + 1];
  39. sprintf (tmp, "%s%s", basename, dirname);
  40. if (0 != access (tmp, R_OK))
  41. {
  42. fprintf (stderr,
  43. _ ("Failed to access `%s': %s\n"),
  44. tmp,
  45. STRERROR (errno));
  46. fprintf (
  47. stderr,
  48. _ (
  49. "Check that you did run `make install' and that GNUNET_PREFIX='%s' is the correct prefix.\n"),
  50. basename);
  51. fprintf (stderr, _ ("Testcases will not work!\n"));
  52. return 2;
  53. }
  54. }
  55. return 0;
  56. }