mirror of
https://github.com/samba-team/samba.git
synced 2025-01-14 19:24:43 +03:00
r10468: - terminate tdbtorture quickly when an error is detected
- more workarounds for aix not handling malloc of size 0 (This used to be commit c2b1739c6389503854f55fa8407c55071781eff4)
This commit is contained in:
parent
6e4ebbed89
commit
3bcfc68e0d
@ -97,6 +97,10 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe)
|
|||||||
static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
|
static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
|
||||||
const void *buf, tdb_len_t len)
|
const void *buf, tdb_len_t len)
|
||||||
{
|
{
|
||||||
|
if (len == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (tdb->read_only || tdb->traverse_read) {
|
if (tdb->read_only || tdb->traverse_read) {
|
||||||
tdb->ecode = TDB_ERR_RDONLY;
|
tdb->ecode = TDB_ERR_RDONLY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -197,6 +197,10 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
|
|||||||
{
|
{
|
||||||
struct tdb_transaction_el *el;
|
struct tdb_transaction_el *el;
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* if the write is to a hash head, then update the transaction
|
/* if the write is to a hash head, then update the transaction
|
||||||
hash heads */
|
hash heads */
|
||||||
if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP &&
|
if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP &&
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
static struct tdb_context *db;
|
static struct tdb_context *db;
|
||||||
static int in_transaction;
|
static int in_transaction;
|
||||||
static int log_count;
|
static int error_count;
|
||||||
|
|
||||||
#ifdef PRINTF_ATTRIBUTE
|
#ifdef PRINTF_ATTRIBUTE
|
||||||
static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
|
static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
|
||||||
@ -59,7 +59,7 @@ static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...)
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
log_count++;
|
error_count++;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vfprintf(stdout, format, ap);
|
vfprintf(stdout, format, ap);
|
||||||
@ -78,7 +78,7 @@ static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...)
|
|||||||
static void fatal(const char *why)
|
static void fatal(const char *why)
|
||||||
{
|
{
|
||||||
perror(why);
|
perror(why);
|
||||||
exit(1);
|
error_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *randbuf(int len)
|
static char *randbuf(int len)
|
||||||
@ -283,37 +283,55 @@ static void usage(void)
|
|||||||
srand(seed + i);
|
srand(seed + i);
|
||||||
srandom(seed + i);
|
srandom(seed + i);
|
||||||
|
|
||||||
for (i=0;i<num_loops;i++) {
|
for (i=0;i<num_loops && error_count == 0;i++) {
|
||||||
addrec_db();
|
addrec_db();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error_count == 0) {
|
||||||
tdb_traverse_read(db, NULL, NULL);
|
tdb_traverse_read(db, NULL, NULL);
|
||||||
tdb_traverse(db, traverse_fn, NULL);
|
tdb_traverse(db, traverse_fn, NULL);
|
||||||
tdb_traverse(db, traverse_fn, NULL);
|
tdb_traverse(db, traverse_fn, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
tdb_close(db);
|
tdb_close(db);
|
||||||
|
|
||||||
if (getpid() == pids[0]) {
|
if (getpid() != pids[0]) {
|
||||||
for (i=0;i<num_procs-1;i++) {
|
return error_count;
|
||||||
int status;
|
}
|
||||||
if (waitpid(pids[i+1], &status, 0) != pids[i+1]) {
|
|
||||||
printf("failed to wait for %d\n",
|
for (i=1;i<num_procs;i++) {
|
||||||
(int)pids[i+1]);
|
int status, j;
|
||||||
|
pid_t pid;
|
||||||
|
if (error_count != 0) {
|
||||||
|
/* try and stop the test on any failure */
|
||||||
|
for (j=1;j<num_procs;j++) {
|
||||||
|
if (pids[j] != 0) {
|
||||||
|
kill(pids[j], SIGTERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pid = waitpid(-1, &status, 0);
|
||||||
|
if (pid == -1) {
|
||||||
|
perror("failed to wait for child\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
for (j=1;j<num_procs;j++) {
|
||||||
|
if (pids[j] == pid) break;
|
||||||
|
}
|
||||||
|
if (j == num_procs) {
|
||||||
|
printf("unknown child %d exited!?\n", pid);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (WEXITSTATUS(status) != 0) {
|
if (WEXITSTATUS(status) != 0) {
|
||||||
printf("child %d exited with status %d\n",
|
printf("child %d exited with status %d\n",
|
||||||
(int)pids[i+1], WEXITSTATUS(status));
|
(int)pid, WEXITSTATUS(status));
|
||||||
exit(1);
|
error_count++;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (log_count == 0) {
|
|
||||||
printf("OK\n");
|
|
||||||
}
|
}
|
||||||
|
pids[j] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_count != 0) {
|
if (error_count == 0) {
|
||||||
exit(1);
|
printf("OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user