xnu_uuid_test.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2013 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/time.h>
  19. #include <grub/misc.h>
  20. #include <grub/dl.h>
  21. #include <grub/command.h>
  22. #include <grub/env.h>
  23. #include <grub/test.h>
  24. #include <grub/mm.h>
  25. GRUB_MOD_LICENSE ("GPLv3+");
  26. static void
  27. xnu_uuid_test (void)
  28. {
  29. grub_command_t cmd;
  30. cmd = grub_command_find ("xnu_uuid");
  31. char *args[] = { (char *) "fedcba98", (char *) "tstvar", NULL };
  32. const char *val;
  33. if (!cmd)
  34. {
  35. grub_test_assert (0, "can't find command `%s'", "xnu_uuid");
  36. return;
  37. }
  38. if ((cmd->func) (cmd, 2, args))
  39. {
  40. grub_test_assert (0, "%d: %s", grub_errno, grub_errmsg);
  41. return;
  42. }
  43. val = grub_env_get ("tstvar");
  44. if (!val)
  45. {
  46. grub_test_assert (0, "tstvar isn't set");
  47. return;
  48. }
  49. grub_test_assert (grub_strcmp (val, "944F9DED-DBED-391C-9402-77C8CEE04173")
  50. == 0, "UUIDs don't match");
  51. }
  52. GRUB_FUNCTIONAL_TEST (xnu_uuid_test, xnu_uuid_test);