Understanding API Usage and Testing: An Empricial Study of C Libraries (Artifact)
<h1>LibProbe Artifact</h1> <p>For the sake of the evaluation we preprocessed the CCScanner data to identify all clients of the libraries used in our evaluation and included those in our <code>MongoDB</code> database. This artifact will start by importing this pre-processed dependency information into a docker image which is then used for the evaluation.</p> <h2>Running the docker image</h2> <ul> <li> <p>First load the docker image by running</p> <ul> <li> <div> <div><code>gunzip -c libprobe_v2.2.tar.gz | sudo docker import - libprobe:latest </code></div> </div> </li> </ul> <p>this will load the image in your local docker images.</p> </li> <li> <p>Run a container from the image: <code>sudo docker run -it --device /dev/snd --privileged libprobe:latest /bin/bash</code> This will run a docker container which maps the pulseaudio and alsa configurations from your local host to the docker image. This is necessary to get some clients for some target libraries to build correctly. You will need an ubuntu host machine which has pulseaudio and alsa installed.</p> </li> <li>Run <code>mongod --fork --logpath /var/log/mongodb/mongod.log</code> followed by <code>mongorestore --drop --db apiusage /tmp/libprobe/database/apiusage</code> to import the results saved in the artifact. </li> </ul> <h2>Validating analysis results</h2> <ul> <li>The docker image provided does not contain any clients due to size limitations on sharing. The Mongo database contains all the results of running this evaluation.</li> <li>We provide a script <code>clone_clients.py</code> with a <code>client_repos.json </code>file in <code>/tmp/libprobe/extra</code> which can be used to clone the clients in the clients directory. </li> <li>To get the results it's possible to run <code>python3 libprobe.py analyse all -n</code> from <code>/tmp/libprobe</code>. This will overwrite the JSON files in the <code>json_files</code> directory and overwrite the graphs in the <code>graphs</code> directory.</li> </ul> <h2>Running the evaluation for one library (vorbis)</h2> <ul> <li>Download clients: Go to <code>/tmp/libprobe</code> and run <code>python3 libprobe.py download vorbis</code></li> <li>Prepare the library: <ul> <li>In /tmp/data/libraries/xiph@@vorbis run make clean then make and make check and make install.</li> <li>Copy all C files from /tmp/data/libraries/xiph@@vorbis/lib to /tmp/data/libraries/xiph@@vorbis/lib/.libs to collect accurate API coverage information.</li> </ul> </li> <li>Process the library to get the APIs and the coverage information : <code>python3 libprobe.py processlib vorbis</code></li> <li>Prepare clients for excluding sub directories that might contain vorbis library code: <code>python3 libprobe.py prepclients vorbis</code></li> <li>Get client usages: <code>python3 libprobe.py fetchusages vorbis</code></li> <li>Analyse: <code>python3 libprobe.py analyse vorbis -n</code></li> <li>(optional) Measure differential coverage for improved coverage libs: <code>python3 libprobe.py coverage vorbis</code></li> </ul> <h2>Running the evaluation for all libraries (this requires at least 300GB of disk space)</h2> <ul> <li>Download clients: Go to <code>\tmp\libprobe</code> and run <code>python3 libprobe.py download all</code></li> <li>Process the libraries: <code>python3 libprobe.py processlib all</code></li> <li>Prepare clients: <code>python3 libprobe.py prepclients all</code></li> <li>Get usages: <code>python3 libprobe.py fetchusages all</code></li> <li>Analyse: <code>python3 libprobe.py analyse all -n</code></li> <li>(optional) Measure differential coverage for improved coverage libs: <code>python3 libprobe.py coverage <library></code></li> </ul> <h2>Getting baseline coverage for libraries</h2> <p>All libraries are cloned in <code>/tmp/data/libraries</code> and clients are cloned in <code>/tmp/data/clients</code>.</p> <div> </div> <ul> <li>MBedtls: Copy the script <code>coverage_mbedtls.sh</code> from <code>/tmp/libprobe/extra</code> into the the build directory of Mbedtls <code>/tmp/data/libraries/Mbed-TLS@@mbedtls/build</code> and run <code>./coverage_mbedtls.sh</code> followed by <code>genhtml baseline.info --output-directory</code> out this will calculate the baseline coverage for mbedtls.</li> <li>FFTW: Copy the script coverage.sh from /tmp/libprobe/extra into the the root dir of FFTW and run ./coverage.sh baseline this will calculate the baseline coverage for fftw</li> <li>HDF5: Copy the script coverage_hdf.sh from /tmp/libprobe/extra into the the root dir of HDF and run <code>./coverage_hdf.sh baseline</code> this will calculate the baseline coverage for HDF.</li> <li>LMDB: Copy the script coverage_lmdb.sh from /tmp/libprobe/extra into the <code>/tmp/data/libraries/LMDB@@lmdb/libraries/liblmdb</code> and run <code>./coverage_lmdb.sh baseline</code> this will calculate the baseline coverage for LMDB.</li> <li>Zip: Copy the script coverage_zip.sh from /tmp/libprobe/extra into <code>/tmp/data/libraries/kuba--@@zip/build/CMakeFiles/zip.dir/sr</code>c and run <code>./coverage_zip.sh baseline</code> this will calculate the baseline coverage for zip.</li> <li>Vorbis: Copy the script cal_cov.py from /tmp/libprobe/extra to <code>/tmp/data/libraries/xiph@@vorbis/lib/.libs</code> and then copy all source files in the <code>.libs</code> folder by running <code>cp ../*.c .</code> from the <code>.libs</code> folder. Finally run <code>python3 cal_cov.py .</code>.</li> <li>XXhash: Copy the script coverage.sh from /tmp/libprobe/extra into /tmp/data/libraries/Cyan4973@@xxHash and run ./coverage.sh baseline this will calculate the baseline coverage for xxhash</li> </ul> <h2>Reproducing increased coverage using clients</h2> <ul> <li> <p>LMDB: The client we will use is Knot DNS.</p> <ul> <li>Change directory to <code>/tmp/data/clients/CZ-NIC@@knot</code> and run <code>autogen.sh</code>.</li> <li>Run <code>./configure --with-lmdb=/usr/local</code>.</li> <li>Then <code>make && make check</code>.</li> </ul> <p>Now go back to the LMDB directory and run</p> <ul> <li> <p>Run <code>./coverage_lmdb.sh after_knot</code>.</p> </li> <li> <p>Now go /tmp/libprobe and run <code>python3 libprobe.py coverage lmdb</code></p> </li> </ul> </li> <li> <p>VORBIS: The client we will use in SFML.</p> <p>Go to the vorbis library dir <code>/tmp/data/libraries/xiph@@vorbis</code> and run <code>make clean</code>.</p> <ul> <li>Run <code>make && make check && make install</code>.</li> <li>Go to the <code>.libs</code> folder and copy all c files there by doing <code>cp ../*.c .</code>.</li> <li>Copy <code>/tmp/libprobe/extra/cal_cov.py</code> into the <code>.libs</code> folder and run <code>python3 cal_cov.py .</code>. This will show the baseline coverage.</li> </ul> <p>Go to the SFML directory <code>/tmp/data/clients/SFML@@SFML</code>.</p> <ul> <li>Create build directory <code>mkdir build && cd build</code>.</li> <li>Run <code>cmake -DSFML_BUILD_TEST_SUITE=TRUE -GNinja ..</code>.</li> <li>Run <code>ninja</code>.</li> <li>Run <code>ctest</code>. You will see some failing tests. Thats normal as we are only interested in the Audio tests for vorbis. All Audio tests should pass.</li> </ul> <p>Go back to the <code>.libs</code> folder in vorbis and re-run the <code>cal_cov.py</code> script.</p> <ul> <li>Now go /tmp/libprobe and run <code>python3 libprobe.py coverage vorbis</code></li> </ul> </li> </ul> <ul> <li>SDL: The client we will use in UFOAI.<br> <ul> <li> <p>Go to the SDL library dir <code>/tmp/data/libraries/libsdl-org\@\@SDL</code> and then the <code>build2</code> directory where the built library is. .</p> </li> <li>Run <code>make clean && make && make install && make test</code>.</li> <li>Copy <code>/tmp/libprobe/extra/coverage_sdl.sh</code> into the <code>build2</code> folder and run <code>./coverage_sdl.sh baseline</code>. Run <code>genhtml baseline.info --output-directory out</code></li> </ul> </li> </ul> <p> Go to the UFOAI directory <code>/tmp/data/clients/ufoaiorg\@\@ufoai</code></p> <ul> <li> <ul> <li>Run <code>./configure --target-os=linux --disable-uforadiant</code> && <code>make</code>.</li> <li>Run .<code>/testall</code></li> </ul> </li> </ul> <p> Now go /tmp/libprobe and run <code>python3 libprobe.py coverage sdl</code></p> <p> </p> <ul> <li>FFTW: The client we will use in CAVA.</li> </ul> <p> Go to the FFTW3 library dir <code>/tmp/data/libraries/FFTW@@fftw3</code> and run <code>reset_cov.sh</code> then <code>make clean</code></p> <ul> <li> <ul> <li>Run <code>make && make install && make check</code>.</li> <li>Copy <code>/tmp/libprobe/extra/coverage.sh</code> into root directory of the library and run the <code>.libs</code> folder and run <code>./coverage.sh baseline</code> This will show the baseline coverage.</li> </ul> </li> </ul> <p> Go to the CAVA directory <code>/tmp/data/clients/karlstav@@cava</code>.</p> <ul> <li> <ul> <li>Run <code>./autogen.sh</code> followed by <code>./configure</code> then <code>make</code></li> <li>Run the script <code>./run_all_tests.sh</code> . </li> </ul> </li> </ul> <p> Go back to the FFTW3 library and run <code>./coverage.sh after_cava</code></p> <ul> <li> <ul> <li>Now go /tmp/libprobe and run <code>python3 libprobe.py coverage fftw3</code></li> </ul> </li> </ul>
ShareScore
40/100
Overall dataset sharing score
Score breakdown
These five areas show where the dataset supports — or may limit — practical reuse.
- Stewardship
- 8
- Harmonization
- 8
- Access
- 16
- Reuse readiness
- 8
- Engagement
- 0