1 /*
2 * Copyright (C) 2021 Alexandros Theodotou <alex at zrythm dot org>
3 *
4 * This file is part of Zrythm
5 *
6 * Zrythm is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Zrythm is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "zrythm-test-config.h"
21
22 #include <stdlib.h>
23
24 #include "utils/file.h"
25 #include "utils/flags.h"
26 #include "utils/io.h"
27
28 #include <glib.h>
29
30 static void
test_symlink(void)31 test_symlink (void)
32 {
33 char * filepath =
34 g_build_filename (
35 TESTS_SRCDIR,
36 "test_start_with_signal.mp3", NULL);
37
38 char * tmp_dir =
39 g_dir_make_tmp ("zrythm_symlink_dir_XXXXXX", NULL);
40 g_assert_nonnull (tmp_dir);
41 char * target =
42 g_build_filename (tmp_dir, "target.mp3", NULL);
43 g_message ("target %s", target);
44
45 g_assert_cmpint (
46 file_symlink (filepath, target), ==, 0);
47 io_remove (target);
48 io_rmdir (tmp_dir, F_NO_FORCE);
49 }
50
51 int
main(int argc,char * argv[])52 main (int argc, char *argv[])
53 {
54 g_test_init (&argc, &argv, NULL);
55
56 #define TEST_PREFIX "/utils/file/"
57
58 g_test_add_func (
59 TEST_PREFIX "test symlink",
60 (GTestFunc) test_symlink);
61
62 return g_test_run ();
63 }
64
65