Skip to content

Commit

Permalink
apply clang-format to Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercosmos committed Jun 21, 2024
1 parent e3128c6 commit 61c6d59
Show file tree
Hide file tree
Showing 68 changed files with 4,873 additions and 4,621 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
hooks:
- id: clang-format
args: ["--style=file"] # Use the .clang-format file for configuration
files: ^Common\+\+/.*\.(cpp|h)$
files: ^(Common\+\+|Tests)/.*\.(cpp|h)$
- id: cppcheck
args: ["--std=c++11", "--language=c++", "--suppressions-list=cppcheckSuppressions.txt", "--inline-suppr", "--force"]
- repo: https://github.com/codespell-project/codespell
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fuzzers/DumpToFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

// This function is created as PcapPlusPlus doesn't seem to offer a way of
// parsing Pcap files directly from memory
static int dumpDataToPcapFile(const uint8_t *data, size_t size, const char* path)
static int dumpDataToPcapFile(const uint8_t* data, size_t size, const char* path)
{
FILE *fd;
FILE* fd;
int written = 0;

fd = fopen(path, "wb");
Expand Down
13 changes: 6 additions & 7 deletions Tests/Fuzzers/FuzzTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
static std::string tmpName;
static std::string tmpFile;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
if (tmpName.empty())
tmpName = tmpnam (NULL);
tmpName = tmpnam(NULL);

if (tmpFile.empty())
tmpFile = tmpName + FILE_EXT;
Expand All @@ -32,15 +32,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

pcpp::IPcapDevice::PcapStats stats;
reader->getStatistics(stats);
std::cout << "Read " << stats.packetsRecv << " packets successfully and "
<< stats.packetsDrop << " packets could not be read" << std::endl;
std::cout << "Read " << stats.packetsRecv << " packets successfully and " << stats.packetsDrop
<< " packets could not be read" << std::endl;

if (auto ngReader = dynamic_cast<pcpp::PcapNgFileReaderDevice*>(reader.get()))
{
std::cout << "OS is '" << ngReader->getOS() << "'; Hardware is '" << ngReader->getHardware() << "'"
<< "'; CaptureApplication is '" << ngReader->getCaptureApplication()
<< "'; CaptureFileComment is '" << ngReader->getCaptureFileComment()
<< "'" << std::endl;
<< "'; CaptureApplication is '" << ngReader->getCaptureApplication() << "'; CaptureFileComment is '"
<< ngReader->getCaptureFileComment() << "'" << std::endl;
}

pcpp::RawPacketVector packets;
Expand Down
12 changes: 6 additions & 6 deletions Tests/Fuzzers/FuzzWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ static std::string tmpFile;
static std::string outPcapFile;
static int writes = 0;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
if (tmpName.empty())
tmpName = tmpnam (NULL);
tmpName = tmpnam(NULL);

if (tmpFile.empty())
tmpFile = tmpName + FILE_EXT;
Expand Down Expand Up @@ -41,9 +41,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
#endif

#ifdef NG_WRITER
pcpp::PcapNgFileWriterDevice pcapWriter(outPcapFile);
pcpp::PcapNgFileWriterDevice pcapWriter(outPcapFile);
#else
pcpp::PcapFileWriterDevice pcapWriter(outPcapFile, pcpp::LINKTYPE_ETHERNET);
pcpp::PcapFileWriterDevice pcapWriter(outPcapFile, pcpp::LINKTYPE_ETHERNET);
#endif
if (writes++ == 10)
{
Expand Down Expand Up @@ -71,8 +71,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

pcpp::IPcapDevice::PcapStats stats;
pcapWriter.getStatistics(stats);
std::cout << "Written " << stats.packetsRecv << " packets successfully to pcap writer and "
<< stats.packetsDrop << " packets could not be written" << std::endl;
std::cout << "Written " << stats.packetsRecv << " packets successfully to pcap writer and " << stats.packetsDrop
<< " packets could not be written" << std::endl;

pcapWriter.close();
return 0;
Expand Down
Loading

0 comments on commit 61c6d59

Please sign in to comment.