forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cstor#128] Remove tgt from zfs repository
Signed-off-by: Jan Kryl <jan.kryl@cloudbyte.com>
- Loading branch information
Jan Kryl
committed
Apr 3, 2018
1 parent
38ec84e
commit 8ed55d3
Showing
11 changed files
with
123 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest zrepl uzfs_test zpios | ||
SUBDIRS += mount_zfs fsck_zfs zvol_id vdev_id arcstat dbufstat zed | ||
SUBDIRS += arc_summary raidz_test zgenhostid tgt dmu_io_test | ||
SUBDIRS += arc_summary raidz_test zgenhostid dmu_io_test | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
#ifndef _UZFS_UTILS_H | ||
#define _UZFS_UTILS_H | ||
|
||
#include <gtest/gtest.h> | ||
|
||
/* Prints errno string if cond is not true */ | ||
#define ASSERT_ERRNO(fname, cond) do { \ | ||
if (!(cond)) { \ | ||
perror(fname); \ | ||
ASSERT_EQ(errno, 0); \ | ||
} \ | ||
} while (0) | ||
|
||
namespace GtestUtils { | ||
std::string execCmd(std::string const &zfsCmd, std::string const &args); | ||
std::string getCmdPath(std::string zfsCmd); | ||
int verify_buf(void *buf, int len, const char *pattern); | ||
void init_buf(void *buf, int len, const char *pattern); | ||
} | ||
|
||
#endif // _UZFS_UTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
#include <cstdio> | ||
#include <iostream> | ||
#include <memory> | ||
#include <stdexcept> | ||
#include <string> | ||
#include <array> | ||
|
||
#include "gtest_utils.h" | ||
|
||
void GtestUtils::init_buf(void *buf, int len, const char *pattern) { | ||
int i; | ||
char c; | ||
int pat_len = strlen(pattern); | ||
|
||
for (i = 0; i < len; i++) { | ||
c = pattern[i % pat_len]; | ||
((char *)buf)[i] = c; | ||
} | ||
} | ||
|
||
int GtestUtils::verify_buf(void *buf, int len, const char *pattern) { | ||
int i; | ||
char c; | ||
int pat_len = strlen(pattern); | ||
|
||
for (i = 0; i < len; i++) { | ||
c = pattern[i % pat_len]; | ||
if (c != ((char *)buf)[i]) | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
std::string GtestUtils::getCmdPath(std::string zfsCmd) { | ||
std::string cmdPath; | ||
const char *srcPath = std::getenv("SRC_PATH"); | ||
|
||
if (srcPath == nullptr) { | ||
cmdPath += "."; | ||
} else { | ||
cmdPath = srcPath; | ||
} | ||
cmdPath += "/cmd/" + zfsCmd + "/" + zfsCmd; | ||
|
||
return cmdPath; | ||
} | ||
|
||
/* | ||
* Executes given zfs command with specified arguments and returns its output | ||
* or throws exception if anything (including the command itself) fails). | ||
*/ | ||
std::string GtestUtils::execCmd(std::string const &zfsCmd, | ||
std::string const &args) { | ||
std::string cmdLine; | ||
std::array<char, 128> buffer; | ||
std::string result; | ||
FILE *pipe; | ||
int rc; | ||
|
||
cmdLine = getCmdPath(zfsCmd) + " " + args; | ||
|
||
pipe = popen(cmdLine.c_str(), "r"); | ||
if (!pipe) | ||
throw std::runtime_error("popen() failed"); | ||
while (!feof(pipe)) { | ||
if (fgets(buffer.data(), 128, pipe) != nullptr) | ||
result += buffer.data(); | ||
} | ||
rc = pclose(pipe); | ||
if (rc != 0) | ||
throw std::runtime_error(std::string("Command failed: ") + | ||
cmdLine); | ||
|
||
return result; | ||
} |
Oops, something went wrong.