GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/upload_spooler_definition.cc
Date: 2026-10-04 02:40:33
Exec Total Coverage
Lines: 32 44 72.7%
Branches: 18 35 51.4%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #include "upload_spooler_definition.h"
6
7 #include <vector>
8
9 #include "util/logging.h"
10 #include "util/string.h"
11
12 namespace upload {
13
14 const char *SpoolerDefinition::kDriverNames[] = {"S3", "local", "gw", "mock",
15 "unknown"};
16
17 2472 SpoolerDefinition::SpoolerDefinition(
18 const std::string &definition_string,
19 const shash::Algorithms hash_algorithm,
20 const zlib::Algorithms compression_algorithm,
21 const bool generate_legacy_bulk_chunks,
22 const bool use_file_chunking,
23 const size_t min_file_chunk_size,
24 const size_t avg_file_chunk_size,
25 const size_t max_file_chunk_size,
26 const std::string &session_token_file,
27 2472 const std::string &key_file)
28 2472 : driver_type(Unknown)
29 2472 , hash_algorithm(hash_algorithm)
30 2472 , compression_alg(compression_algorithm)
31 2472 , generate_legacy_bulk_chunks(generate_legacy_bulk_chunks)
32 2472 , use_file_chunking(use_file_chunking)
33 2472 , min_file_chunk_size(min_file_chunk_size)
34 2472 , avg_file_chunk_size(avg_file_chunk_size)
35 2472 , max_file_chunk_size(max_file_chunk_size)
36 2472 , number_of_concurrent_uploads(kDefaultMaxConcurrentUploads)
37 2472 , num_upload_tasks(kDefaultNumUploadTasks)
38
1/2
✓ Branch 1 taken 2472 times.
✗ Branch 2 not taken.
2472 , session_token_file(session_token_file)
39
1/2
✓ Branch 1 taken 2472 times.
✗ Branch 2 not taken.
2472 , key_file(key_file)
40 2472 , valid_(false) {
41 // check if given file chunking values are sane
42
2/2
✓ Branch 0 taken 2414 times.
✓ Branch 1 taken 58 times.
2472 if (use_file_chunking
43
1/2
✓ Branch 0 taken 2414 times.
✗ Branch 1 not taken.
2414 && (min_file_chunk_size >= avg_file_chunk_size
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2414 times.
2414 || avg_file_chunk_size >= max_file_chunk_size)) {
45 ✗ LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
46 ✗ return;
47 }
48
49 // split the spooler driver definition into name and config part
50
1/2
✓ Branch 1 taken 2472 times.
✗ Branch 2 not taken.
2472 std::vector<std::string> upstream = SplitString(definition_string, ',');
51
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2472 times.
2472 if (upstream.size() != 3) {
52 ✗ LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
53 ✗ return;
54 }
55
56 // recognize and configure the spooler driver
57
2/2
✓ Branch 2 taken 566 times.
✓ Branch 3 taken 1906 times.
2472 if (upstream[0] == "local") {
58 566 driver_type = Local;
59
2/2
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 1750 times.
1906 } else if (upstream[0] == "S3") {
60 156 driver_type = S3;
61
2/2
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 1692 times.
1750 } else if (upstream[0] == "gw") {
62 58 driver_type = Gateway;
63
1/2
✓ Branch 2 taken 1692 times.
✗ Branch 3 not taken.
1692 } else if (upstream[0] == "mock") {
64 1692 driver_type = Mock; // for unit testing purpose only!
65 } else {
66 ✗ driver_type = Unknown;
67 ✗ LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
68 ✗ upstream[0].c_str());
69 ✗ return;
70 }
71
72 // save data
73
1/2
✓ Branch 2 taken 2472 times.
✗ Branch 3 not taken.
2472 temporary_path = upstream[1];
74
1/2
✓ Branch 2 taken 2472 times.
✗ Branch 3 not taken.
2472 spooler_configuration = upstream[2];
75 2472 valid_ = true;
76
1/2
✓ Branch 1 taken 2472 times.
✗ Branch 2 not taken.
2472 }
77
78 ✗ SpoolerDefinition SpoolerDefinition::Dup2DefaultCompression() const {
79 ✗ SpoolerDefinition result(*this);
80 ✗ result.compression_alg = zlib::kZlibDefault;
81 ✗ return result;
82 }
83
84 } // namespace upload
85