Skip to content

Commit

Permalink
Enhancement CiscoDevNet#853
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Gorelik committed Jan 30, 2019
1 parent c9e4a2e commit bebd554
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ protobuf-3.5.0
sdk/python/gnmi/build
sdk/python/gnmi/dist
sdk/python/gnmi/ydk_service_gnmi.egg-info
sdk/cpp/core/tests/repository/*
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ matrix:
dist: trusty
group: edge
- os: osx
osx_image: xcode8.3
osx_image: xcode7.3
language: generic
# - os: osx
# env: GNMI=true
Expand Down
7 changes: 6 additions & 1 deletion sdk/cpp/core/src/path/repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,12 @@ ly_ctx* ydk::path::RepositoryPtr::create_ly_context()
{
for(auto model_provider : get_model_providers())
{
path+="/"+model_provider->get_hostname_port();
//path+="/"+model_provider->get_hostname_port();
auto hostname_port = model_provider->get_hostname_port();
auto underscore_pos = hostname_port.rfind("_");
if (underscore_pos != std::string::npos)
hostname_port = hostname_port.substr(0, underscore_pos);
path += "/" + hostname_port;
break;
}
}
Expand Down
27 changes: 26 additions & 1 deletion sdk/cpp/gnmi/tests/test_gnmi_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
------------------------------------------------------------------*/
#include <string.h>
#include <iostream>
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <ydk/gnmi_provider.hpp>
#include <ydk/gnmi_service.hpp>
Expand Down Expand Up @@ -45,9 +49,30 @@ TEST_CASE("GNMICreateNoRepo")
CHECK_NOTHROW(provider.get_encoding());
}

static std::string get_temp_model_path()
{
const char *homeDir = getenv("HOME");
if (!homeDir) {
struct passwd* pwd = getpwuid(getuid());
if (pwd)
homeDir = pwd->pw_dir;
}

std::ostringstream models_path{};
models_path << homeDir << "/.ydk/temp";
auto path = models_path.str();

struct stat st;
memset(&st, 0, sizeof(struct stat));
if (stat(path.c_str(), &st) == -1) {
mkdir(path.c_str(), 0755);
}
return path;
}

TEST_CASE("GNMICreateWithNoFiles")
{
ydk::path::Repository repo{};
ydk::path::Repository repo{get_temp_model_path()};
gNMIServiceProvider provider{repo, "127.0.0.1", 50051, "admin", "admin"};
gNMIService gs{};

Expand Down

0 comments on commit bebd554

Please sign in to comment.