2 minute read

How to test code coverage in a C/C++ project, what is IPFS, QUIC. Few words but extremely interesting topics.

Code coverage

A developer should validate its code with tests to prove that all code is necessary and there are no lines or functions that are never executed. gcc suite provides a tool called gcov that produces many code coverage measures, like number of lines executed, branch coverage, loop coverage, etc. To enable code coverage analysis, first source files have to be compiled with these two additional options: -fprofile-arcs -ftest-coverage. When tests are executed, .gcno and .gcda files are generated for the files compiled with the 2 options and code coverage result is provided with the command gcov <source file>. In summary, code coverage tells the tests covering a certain portion of the code, so that changes can be validated by a subset of the tests. See this clear post for an easy example.

IPFS

Inter-Planetary File System is a distributed system for storing and accessing files, websites, applications, and data. It is a peer-to-peer storage network. It aims at making Internet contents available to everyone and not in control of few entities. The same data can be stored redundantly across different peers so that if one shuts down, another peer stores a backup. Moreover, given that more peers stores the same data, a user can retireve the resource from the closest peer.

A major difference with WWW is that resources are not accessed by their locations, as it happens for URLs, but data is accessed through its content that is hashed. This technique is called content addressing. Like in Git, IPFS uses Merkle DAGs (Directed Acyclic Graphs) to represent directories and files. Content is split in blocks so that only a subset of the blocks is updated in case of changes, while the others can be reused. Eventually, once the required content has been identified, a DHT (Distributed Hashed Table) is necessary to find the peers hosting that content.

IPFS is a broad topic and needs a deeper study to fully appreciate its power. Official docs seems a good start point where to start learning.

QUIC

It is a transport layer protocol for supporting web application more efficiently than TCP because it was designed to support HTTPS. The main features are:

  • TLS security parameters are established immediately reducing time for handshakes
  • runs over UDP
  • Congestion control algorithms are moved from kernel to user space to make easier their development
  • connections are multiplexed

Leave a comment