2 Unix SMB/CIFS implementation.
3 chkpath individual test suite
4 Copyright (C) Andrew Tridgell 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program 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 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define BASEDIR "\\rawchkpath"
25 #define CHECK_STATUS(status, correct) do { \
26 if (!NT_STATUS_EQUAL(status, correct)) { \
27 printf("(%d) Incorrect status %s - should be %s\n", \
28 __LINE__, nt_errstr(status), nt_errstr(correct)); \
34 static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
36 struct smb_chkpath io;
43 status = smb_raw_chkpath(cli->tree, &io);
44 CHECK_STATUS(status, NT_STATUS_OK);
46 io.in.path = BASEDIR "\\nodir";
47 status = smb_raw_chkpath(cli->tree, &io);
48 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
50 fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\test.txt");
52 printf("failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
57 io.in.path = BASEDIR "\\test.txt";
58 printf("testing %s\n", io.in.path);
59 status = smb_raw_chkpath(cli->tree, &io);
60 CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
62 if (!torture_set_file_attribute(cli->tree, BASEDIR, FILE_ATTRIBUTE_HIDDEN)) {
63 printf("failed to set basedir hidden\n");
69 printf("testing %s\n", io.in.path);
70 status = smb_raw_chkpath(cli->tree, &io);
71 CHECK_STATUS(status, NT_STATUS_OK);
74 printf("testing %s\n", io.in.path);
75 status = smb_raw_chkpath(cli->tree, &io);
76 CHECK_STATUS(status, NT_STATUS_OK);
79 printf("testing %s\n", io.in.path);
80 status = smb_raw_chkpath(cli->tree, &io);
81 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
84 printf("testing %s\n", io.in.path);
85 status = smb_raw_chkpath(cli->tree, &io);
86 CHECK_STATUS(status, NT_STATUS_OK);
89 printf("testing %s\n", io.in.path);
90 status = smb_raw_chkpath(cli->tree, &io);
91 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
94 printf("testing %s\n", io.in.path);
95 status = smb_raw_chkpath(cli->tree, &io);
96 CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
98 io.in.path = BASEDIR "\\.";
99 printf("testing %s\n", io.in.path);
100 status = smb_raw_chkpath(cli->tree, &io);
101 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
103 io.in.path = BASEDIR "\\..";
104 printf("testing %s\n", io.in.path);
105 status = smb_raw_chkpath(cli->tree, &io);
106 CHECK_STATUS(status, NT_STATUS_OK);
108 io.in.path = BASEDIR "\\nt\\Visual Studio\\VB98\\vb600";
109 printf("testing %s\n", io.in.path);
110 status = smb_raw_chkpath(cli->tree, &io);
111 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
113 io.in.path = BASEDIR "\\nt\\Visual Studio\\VB98\\vb6.exe";
114 printf("testing %s\n", io.in.path);
115 status = smb_raw_chkpath(cli->tree, &io);
116 CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
118 io.in.path = BASEDIR "\\nt\\Visual Studio\\VB98\\vb6.exe\\3";
119 printf("testing %s\n", io.in.path);
120 status = smb_raw_chkpath(cli->tree, &io);
121 CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
123 io.in.path = BASEDIR "\\nt\\Visual Studio\\*\\vb6.exe\\3";
124 printf("testing %s\n", io.in.path);
125 status = smb_raw_chkpath(cli->tree, &io);
126 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
129 smbcli_close(cli->tree, fnum);
134 basic testing of chkpath calls
136 BOOL torture_raw_chkpath(int dummy)
138 struct smbcli_state *cli;
143 if (!torture_open_connection(&cli)) {
147 mem_ctx = talloc_init("torture_raw_chkpath");
149 if (smbcli_deltree(cli->tree, BASEDIR) == -1) {
150 printf("Failed to clean " BASEDIR "\n");
153 if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
154 printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
158 if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt"))) {
159 printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
163 if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\Visual Studio"))) {
164 printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
168 if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\Visual Studio\\VB98"))) {
169 printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
173 fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\nt\\Visual Studio\\VB98\\vb6.exe");
175 printf("failed to open \\nt\\Visual Studio\\VB98\\vb6.exe - %s\n", smbcli_errstr(cli->tree));
180 if (!test_chkpath(cli, mem_ctx)) {
186 smb_raw_exit(cli->session);
187 smbcli_deltree(cli->tree, BASEDIR);
189 torture_close_connection(cli);
190 talloc_destroy(mem_ctx);