Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cstor#128] Remove tgt from zfs repository #32

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/Makefile.am
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

1 change: 0 additions & 1 deletion cmd/tgt/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions cmd/tgt/Makefile.am

This file was deleted.

199 changes: 0 additions & 199 deletions cmd/tgt/tgt.c

This file was deleted.

9 changes: 8 additions & 1 deletion cmd/zrepl/zrepl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <syslog.h>
#include <libuzfs.h>
#include <libzfs.h>
#include <sys/dsl_dataset.h>
#include <sys/dmu_objset.h>
#include <uzfs_mgmt.h>
#include <zrepl_mgmt.h>
#include <uzfs_io.h>
Expand Down Expand Up @@ -563,7 +565,12 @@ uzfs_zvol_mgmt_do_handshake(zvol_io_hdr_t *hdr, int sfd, char *name)
uzfs_zvol_get_last_committed_io_no(zv,
&hdr->checkpointed_io_seq);
mgmt_ack.pool_guid = spa_guid(zv->zv_spa);
mgmt_ack.zvol_guid = dmu_objset_fsid_guid(zv->zv_objset);
/*
* We don't use fsid_guid because that one is not guaranteed
* to stay the same (it is changed in case of conflicts).
*/
mgmt_ack.zvol_guid = dsl_dataset_phys(
zv->zv_objset->os_dsl_dataset)->ds_guid;
uzfs_zinfo_drop_refcnt(zinfo, B_FALSE);
}

Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ AC_CONFIG_FILES([
cmd/zdb/Makefile
cmd/zhack/Makefile
cmd/zfs/Makefile
cmd/tgt/Makefile
cmd/zinject/Makefile
cmd/zpool/Makefile
cmd/zstreamdump/Makefile
Expand Down
3 changes: 2 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ USER_H = \
$(top_srcdir)/include/uzfs_zap.h \
$(top_srcdir)/include/uzfs.h \
$(top_srcdir)/include/uzfs_task.h \
$(top_srcdir)/include/uzfs_rebuilding.h
$(top_srcdir)/include/uzfs_rebuilding.h \
$(top_srcdir)/include/gtest_utils.h

EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)

Expand Down
22 changes: 22 additions & 0 deletions include/gtest_utils.h
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
2 changes: 1 addition & 1 deletion tests/cbtest/gtest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = test_uzfs test_zrepl_prot

test_uzfs_SOURCES = test_uzfs.cc
test_zrepl_prot_SOURCES = test_zrepl_prot.cc
test_zrepl_prot_SOURCES = test_zrepl_prot.cc gtest_utils.cc

test_uzfs_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
77 changes: 77 additions & 0 deletions tests/cbtest/gtest/gtest_utils.cc
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;
}
Loading