Skip to content

Commit

Permalink
Added Debug Prints
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis committed Sep 30, 2022
1 parent 784c425 commit af56216
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/credentials/tests/TestCommissionerDUTVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <nlunit-test.h>

#include <dirent.h>
#include <filesystem>
#include <stdio.h>
#include <string>

Expand All @@ -52,17 +51,21 @@ static void OnAttestationInformationVerificationCallback(void * context, const D

static void TestCommissionerDUTVectors(nlTestSuite * inSuite, void * inContext)
{
constexpr char kCommissionerDUTTestVectorsRootPath[] = "../../credentials/development/commissioner_dut";

DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore());
NL_TEST_ASSERT(inSuite, example_dac_verifier != nullptr);

DIR * dir = opendir(kCommissionerDUTTestVectorsRootPath);
NL_TEST_ASSERT(inSuite, dir != nullptr);

char cwd[256];
getcwd(cwd, sizeof(cwd));
fprintf(stderr, "DEBUG PRINT 00: %s\n", cwd);
std::string dirPath("../../../../../credentials/development/commissioner_dut/");
DIR * dir = opendir(dirPath.c_str());
while (dir == nullptr && (dirPath.find("../") == 0))
{
dirPath = dirPath.substr(3);
dir = opendir(dirPath.c_str());
}
if (dir == nullptr)
{
ChipLogError(Crypto, "Couldn't open folder with Commissioner DUT Test Vectors.");
return;
}

dirent * entry;
while ((entry = readdir(dir)) != nullptr)
Expand All @@ -74,8 +77,7 @@ static void TestCommissionerDUTVectors(nlTestSuite * inSuite, void * inContext)
if (strstr(entry->d_name, "struct_dac_sig_curve_secp256k1"))
continue;

std::string jsonFilePath(kCommissionerDUTTestVectorsRootPath);
jsonFilePath += std::string("/") + std::string(entry->d_name) + std::string("/test_case_vector.json");
std::string jsonFilePath = dirPath + std::string(entry->d_name) + std::string("/test_case_vector.json");

chip::Credentials::Examples::TestHarnessDACProvider dacProvider;
dacProvider.Init(jsonFilePath.c_str());
Expand Down Expand Up @@ -155,14 +157,17 @@ static void TestCommissionerDUTVectors(nlTestSuite * inSuite, void * inContext)
isSuccessCase = true;
}

fprintf(stderr, "DEBUG PRINT 01: %s\n", cwd);
if (!isSuccessCase && (attestationResult == AttestationVerificationResult::kSuccess))
{
fprintf(stderr, "DEBUG PRINT 02: %s\n", jsonFilePath.c_str());
}

if (isSuccessCase)
{
NL_TEST_ASSERT(inSuite, attestationResult == AttestationVerificationResult::kSuccess);
}
else
{
fprintf(stderr, "DEBUG PRINT 02: %s\n", jsonFilePath.c_str());
NL_TEST_ASSERT(inSuite, attestationResult != AttestationVerificationResult::kSuccess);
}
}
Expand Down

0 comments on commit af56216

Please sign in to comment.