yaffsfs.c: Fix NULL dereference in yaffs_unmount2_reldev()
[yaffs2.git] / direct / test-framework / unit_tests / quick_tests / test_yaffs_rename_dir_not_empty.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2018 Aleph One Ltd.
5  *
6  * Created by Timothy Manning <timothy@yaffs.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include "test_yaffs_rename_dir.h"
14
15 /*tests renaming a non empty file */
16 int test_yaffs_rename_dir(void)
17 {
18         int output=0;
19         int error_code =0;
20         output = yaffs_open(YAFFS_MOUNT_POINT "/new_directory/file",O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
21         if (output < 0 )
22
23         if (0 !=  yaffs_access(FILE_PATH,0)) {
24                 output = test_yaffs_open();
25                 if (output < 0) {
26                         print_message("failed to create file\n",2);
27                         return -1;
28                 }
29         }
30         output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH);
31         return output;  
32 }
33
34
35 int test_yaffs_rename_dir_clean(void)
36 {
37         int output = 0;
38         if (0 ==  yaffs_access(YAFFS_MOUNT_POINT "/new_directory/file",0)) {
39                 output = yaffs_unlink(YAFFS_MOUNT_POINT "/new_directory/file");
40                 if (output < 0) {
41                         print_message("failed to remove file\n",2);
42                         return -1;
43                 }
44         }
45
46         if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
47                 output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH);
48                 if (output < 0) {
49                         print_message("failed to rename the dir\n",2);
50                         return -1;
51                 }
52         }
53         return 1;
54
55 }
56