| 1 |
/* |
| 2 |
Unix SMB/CIFS implementation. |
| 3 |
SMB torture tester |
| 4 |
Copyright (C) Guenther Deschner 2010 |
| 5 |
|
| 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 3 of the License, or |
| 9 |
(at your option) any later version. |
| 10 |
|
| 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. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "includes.h" |
| 21 |
#include "torture/smbtorture.h" |
| 22 |
#include <netapi.h> |
| 23 |
#include "torture/libnetapi/proto.h" |
| 24 |
|
| 25 |
#define NETAPI_STATUS(tctx, x,y,fn) \ |
| 26 |
torture_warning(tctx, "FAILURE: line %d: %s failed with status: %s (%d)\n", \ |
| 27 |
__LINE__, fn, libnetapi_get_error_string(x,y), y); |
| 28 |
|
| 29 |
bool torture_libnetapi_server(struct torture_context *tctx) |
| 30 |
{ |
| 31 |
NET_API_STATUS status = 0; |
| 32 |
uint8_t *buffer = NULL; |
| 33 |
int i; |
| 34 |
|
| 35 |
const char *hostname = torture_setting_string(tctx, "host", NULL); |
| 36 |
struct libnetapi_ctx *ctx; |
| 37 |
|
| 38 |
torture_assert(tctx, torture_libnetapi_init_context(tctx, &ctx), |
| 39 |
"failed to initialize libnetapi"); |
| 40 |
|
| 41 |
torture_comment(tctx, "NetServer tests\n"); |
| 42 |
|
| 43 |
torture_comment(tctx, "Testing NetRemoteTOD\n"); |
| 44 |
|
| 45 |
status = NetRemoteTOD(hostname, &buffer); |
| 46 |
if (status) { |
| 47 |
NETAPI_STATUS(tctx, ctx, status, "NetRemoteTOD"); |
| 48 |
goto out; |
| 49 |
} |
| 50 |
NetApiBufferFree(buffer); |
| 51 |
|
| 52 |
torture_comment(tctx, "Testing NetRemoteTOD 10 times\n"); |
| 53 |
|
| 54 |
for (i=0; i<10; i++) { |
| 55 |
status = NetRemoteTOD(hostname, &buffer); |
| 56 |
if (status) { |
| 57 |
NETAPI_STATUS(tctx, ctx, status, "NetRemoteTOD"); |
| 58 |
goto out; |
| 59 |
} |
| 60 |
NetApiBufferFree(buffer); |
| 61 |
} |
| 62 |
|
| 63 |
status = 0; |
| 64 |
|
| 65 |
torture_comment(tctx, "NetServer tests succeeded\n"); |
| 66 |
out: |
| 67 |
if (status != 0) { |
| 68 |
torture_comment(tctx, "NetServer testsuite failed with: %s\n", |
| 69 |
libnetapi_get_error_string(ctx, status)); |
| 70 |
libnetapi_free(ctx); |
| 71 |
return false; |
| 72 |
} |
| 73 |
|
| 74 |
libnetapi_free(ctx); |
| 75 |
return true; |
| 76 |
} |