GCC Code Coverage Report


Directory: ./
File: Os/ValidatedFile.cpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 13 21 61.9%
Functions: 4 7 57.1%
Branches: 3 3 100.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title ValidatedFile.cpp
3 // \author bocchino
4 // \brief Os::ValidatedFile implementation
5 //
6 // \copyright
7 // Copyright (C) 2017 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12
13 #include "Os/ValidatedFile.hpp"
14 #include "Fw/Types/Assert.hpp"
15 #include "Utils/Hash/Hash.hpp"
16
17 namespace Os {
18
19
2/2
✓ Branch 7 taken 21 times.
✓ Branch 12 taken 21 times.
21 ValidatedFile ::ValidatedFile(const char* const fileName) : m_fileName(fileName), m_hashFileName(""), m_hashBuffer() {
20
1/1
✓ Branch 6 taken 21 times.
21 const Fw::FormatStatus formatStatus = Utils::Hash::addFileExtension(this->m_fileName, this->m_hashFileName);
21 // A truncated hash file name would silently validate against the wrong file
22 21 FW_ASSERT(formatStatus == Fw::FormatStatus::SUCCESS, static_cast<FwAssertArgType>(formatStatus));
23 21 }
24
25 6 Os::ValidateFile::Status ValidatedFile ::validate() {
26 const Os::ValidateFile::Status status =
27 6 Os::ValidateFile::validate(this->m_fileName.toChar(), this->m_hashFileName.toChar(), this->m_hashBuffer);
28 6 return status;
29 }
30
31 Os::ValidateFile::Status ValidatedFile ::createHashFile() {
32 const Os::ValidateFile::Status status = Os::ValidateFile::createValidation(
33 this->m_fileName.toChar(), this->m_hashFileName.toChar(), this->m_hashBuffer);
34 return status;
35 }
36
37 13 Os::ValidateFile::Status ValidatedFile ::createHashFile(const Utils::HashBuffer& hashBuffer) {
38 13 this->m_hashBuffer = hashBuffer;
39 const Os::ValidateFile::Status status =
40 13 Os::ValidateFile::createValidation(this->m_hashFileName.toChar(), this->m_hashBuffer);
41 13 return status;
42 }
43
44 const Fw::ConstStringBase& ValidatedFile ::getFileName() const {
45 return this->m_fileName;
46 }
47
48 3 const Fw::ConstStringBase& ValidatedFile ::getHashFileName() const {
49 3 return this->m_hashFileName;
50 }
51
52 const Utils::HashBuffer& ValidatedFile ::getHashBuffer() const {
53 return this->m_hashBuffer;
54 }
55
56 } // namespace Os
57