copy.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright 2021 Hugh McMaster
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  17. */
  18. #include "reg_test.h"
  19. #define COPY_DEST KEY_WINE "\\reg_copy"
  20. static void test_copy(void)
  21. {
  22. DWORD r;
  23. delete_tree(HKEY_CURRENT_USER, KEY_BASE);
  24. verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
  25. run_reg_exe("reg copy", &r);
  26. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  27. run_reg_exe("reg copy /?", &r);
  28. todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
  29. run_reg_exe("reg copy /h", &r);
  30. todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
  31. run_reg_exe("reg copy -H", &r);
  32. todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
  33. run_reg_exe("reg copy /? /f", &r);
  34. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  35. run_reg_exe("reg copy /h /f", &r);
  36. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  37. run_reg_exe("reg copy /? /s", &r);
  38. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  39. run_reg_exe("reg copy /h /s", &r);
  40. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  41. run_reg_exe("reg copy /f", &r);
  42. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  43. run_reg_exe("reg copy /s", &r);
  44. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  45. run_reg_exe("reg copy /s /f", &r);
  46. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  47. run_reg_exe("reg copy /f /s", &r);
  48. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  49. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " /f", &r);
  50. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  51. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " foo /f", &r);
  52. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  53. run_reg_exe("reg copy /f HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" KEY_BASE, &r);
  54. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  55. run_reg_exe("reg copy /f HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" COPY_DEST, &r);
  56. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  57. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " /f HKEY_CURRENT_USER\\" COPY_DEST, &r);
  58. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  59. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " /s HKEY_CURRENT_USER\\" COPY_DEST, &r);
  60. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  61. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" COPY_DEST " /a", &r);
  62. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  63. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" COPY_DEST " /f /a", &r);
  64. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  65. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" KEY_BASE, &r);
  66. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  67. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" KEY_BASE " /f", &r);
  68. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  69. run_reg_exe("reg copy HKEY_CURRENT_USER\\" KEY_BASE " HKEY_CURRENT_USER\\" KEY_BASE " /s /f", &r);
  70. ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
  71. }
  72. START_TEST(copy)
  73. {
  74. DWORD r;
  75. if (!run_reg_exe("reg.exe /?", &r)) {
  76. win_skip("reg.exe not available, skipping 'copy' tests\n");
  77. return;
  78. }
  79. test_copy();
  80. }