1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_SYSTEM_TEST_H
16 #define CEPH_SYSTEM_TEST_H
23 #include "common/Preforker.h"
25 #define RETURN1_IF_NOT_VAL(expected, expr) \
27 int _rinv_ret = expr;\
28 if (_rinv_ret != expected) {\
29 printf("%s: file %s, line %d: expected %d, got %d\n",\
30 get_id_str(), __FILE__, __LINE__, expected, _rinv_ret);\
35 #define RETURN1_IF_NONZERO(expr) \
36 RETURN1_IF_NOT_VAL(0, expr)
38 extern void* systest_runnable_pthread_helper(void *arg);
39 std::string get_temp_pool_name(const char* prefix);
40 /* Represents a single test thread / process.
42 * Inherit from this class and implement the test body in run().
47 static const int ID_STR_SZ = 128;
49 SysTestRunnable(int argc, const char **argv);
50 virtual ~SysTestRunnable();
52 /* Returns 0 on success; error code otherwise. */
53 virtual int run() = 0;
55 /* Return a string identifying the runnable. */
56 const char* get_id_str(void) const;
58 /* Start the Runnable */
61 /* Wait until the Runnable is finished. Returns an error string on failure. */
64 /* Starts a bunch of SystemTestRunnables and waits until they're done.
66 * Returns an error string on failure. */
67 static std::string run_until_finished(std::vector < SysTestRunnable * >&
75 explicit SysTestRunnable(const SysTestRunnable &rhs);
76 SysTestRunnable& operator=(const SysTestRunnable &rhs);
77 void update_id_str(bool started);
78 void set_argv(int argc, const char **argv);
80 friend void* systest_runnable_pthread_helper(void *arg);
83 const char **m_argv_orig;
87 char m_id_str[ID_STR_SZ];