2 Unix SMB/CIFS implementation.
3 ioctl 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 "\\rawioctl"
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 /* test some ioctls */
35 static BOOL test_ioctl(struct cli_state *cli, TALLOC_CTX *mem_ctx)
41 const char *fname = BASEDIR "\\test.dat";
43 printf("TESTING IOCTL FUNCTIONS\n");
45 fnum = create_complex_file(cli, mem_ctx, fname);
47 printf("Failed to create test.dat - %s\n", cli_errstr(cli));
52 printf("Trying QUERY_JOB_INFO\n");
54 ctl.in.request = IOCTL_QUERY_JOB_INFO;
56 status = smb_raw_ioctl(cli->tree, mem_ctx, &ctl);
57 CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
59 printf("Trying bad handle\n");
61 status = smb_raw_ioctl(cli->tree, mem_ctx, &ctl);
62 CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
69 /* test some filesystem control functions */
70 static BOOL test_fsctl(struct cli_state *cli, TALLOC_CTX *mem_ctx)
75 const char *fname = BASEDIR "\\test.dat";
76 struct smb_ntioctl nt;
78 printf("\nTESTING FSCTL FUNCTIONS\n");
80 fnum = create_complex_file(cli, mem_ctx, fname);
82 printf("Failed to create test.dat - %s\n", cli_errstr(cli));
87 printf("trying sparse file\n");
88 nt.in.function = FSCTL_SET_SPARSE;
93 status = smb_raw_ntioctl(cli->tree, &nt);
94 CHECK_STATUS(status, NT_STATUS_OK);
96 printf("Trying bad handle\n");
98 status = smb_raw_ntioctl(cli->tree, &nt);
99 CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
103 for (i=0;i<100;i++) {
104 nt.in.function = FSCTL_FILESYSTEM + (i<<2);
105 status = smb_raw_ntioctl(cli->tree, &nt);
106 if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
107 printf("filesystem fsctl 0x%x - %s\n",
108 i, nt_errstr(status));
114 cli_close(cli, fnum);
119 basic testing of some ioctl calls
121 BOOL torture_raw_ioctl(int dummy)
123 struct cli_state *cli;
127 if (!torture_open_connection(&cli)) {
131 mem_ctx = talloc_init("torture_raw_ioctl");
133 if (cli_deltree(cli, BASEDIR) == -1) {
134 printf("Failed to clean " BASEDIR "\n");
137 if (!cli_mkdir(cli, BASEDIR)) {
138 printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli));
142 if (!test_ioctl(cli, mem_ctx)) {
146 if (!test_fsctl(cli, mem_ctx)) {
150 smb_raw_exit(cli->session);
151 cli_deltree(cli, BASEDIR);
153 torture_close_connection(cli);
154 talloc_destroy(mem_ctx);