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 cli_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", cli_errstr(cli));
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_OK);
104 cli_close(cli, fnum);
109 basic testing of chkpath calls
111 BOOL torture_raw_chkpath(int dummy)
113 struct cli_state *cli;
117 if (!torture_open_connection(&cli)) {
121 mem_ctx = talloc_init("torture_raw_chkpath");
123 if (cli_deltree(cli, BASEDIR) == -1) {
124 printf("Failed to clean " BASEDIR "\n");
127 if (!cli_mkdir(cli, BASEDIR)) {
128 printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli));
132 if (!test_chkpath(cli, mem_ctx)) {
136 smb_raw_exit(cli->session);
137 cli_deltree(cli, BASEDIR);
139 torture_close_connection(cli);
140 talloc_destroy(mem_ctx);