Skip to content

Commit b0b2de6

Browse files
committed
Add a libxtest installing script
Add a script to directly install "libxtest" as a library installed in "/usr/lib/". Signed-off-by: Ayush Joshi <[email protected]>
1 parent 39d18b4 commit b0b2de6

7 files changed

+50
-249
lines changed

README.md

+9-237
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
<div id="top"></div>
22

3-
<div align="center">
4-
5-
[![Contributors][xtest_contributors]][xtest_contributors_url]
6-
[![Forks][xtest_forks]][xtest_forks_url]
7-
[![Stargazers][xtest_stars]][xtest_stars_url]
8-
[![Issues][xtest_issues]][xtest_issues_url]
9-
[![LICENSE][xtest_license]][xtest_license_url]
10-
[![LinkedIn][developer_linkedin]][developer_linkedin_url]
11-
12-
</div>
13-
143
<br/>
154

165
<div align="center">
@@ -19,7 +8,7 @@
198
</a>
209
<h3 align="center">xtest</h3>
2110
<p align="center">
22-
C++ testing framework inspired by <a href="https://github.com/google/googletest"><strong>googletest</strong></a>
11+
C++ testing framework inspired by <a href="https://github.com/google/googletest"><strong>googletest</strong></a>!
2312
<br />
2413
<a href="https://github.com/joshiayush/xtest/tree/master/docs"><strong>Explore the docs »</strong></a>
2514
<br />
@@ -32,136 +21,9 @@
3221
</p>
3322
</div>
3423

35-
<details>
36-
<summary>Contents</summary>
37-
<ol>
38-
<li>
39-
<a href="#xtest">xtest</a>
40-
<ul>
41-
<a href="#commence">Commence</a>
42-
<ul>
43-
<li>
44-
<a href="#prerequisites">Prerequisites</a>
45-
<ul>
46-
<li><a href="#ubuntu">Ubuntu</a></li>
47-
</ul>
48-
</li>
49-
<li><a href="#installation">Installation</a></li>
50-
</ul>
51-
</ul>
52-
</li>
53-
<li><a href="#usage">Usage</a></li>
54-
<li><a href="#contribution">Contribution</a></li>
55-
<li><a href="#license">License</a></li>
56-
<li><a href="#developers">Developers</a></li>
57-
<li><a href="#acknowledgments">Acknowledgments</a></li>
58-
</ol>
59-
</details>
60-
61-
# xtest
62-
6324
**xtest** is a C++ testing framework inspired by [`gtest`][_gtest]. This is just a minimal implementation of a C++ unit testing framework which gives all the required facilities for unit testing a software without going template crazy and causing compilation issues.
6425

65-
A better and more robust version of this library is [`GoogleTest`][_gtest] which is developed and maintained by Google. It is a official Google product and is used by many notable projects.
66-
67-
<div align="right">
68-
<a href="#top">
69-
70-
![Back to top][back_to_top]
71-
72-
</a>
73-
</div>
74-
75-
# Commence
76-
77-
To download and install library [**xtest**][_xtest] in your system follow the following steps.
78-
79-
## Prerequisites
80-
81-
You must have a `g++ 9.3.0` or greater version with a `cmake` version `3.16.3` or _higher_ installed in your system.
82-
83-
### Ubuntu
84-
85-
**Step 1: Install gcc**
86-
87-
```shell
88-
sudo apt update
89-
sudo apt install build-essential
90-
```
91-
92-
If this is the first time you are installing `g++` then you may also want to install the manual pages about using GNU/Linux for development.
93-
94-
```shell
95-
sudo apt install manpages-dev
96-
```
97-
98-
Verify that the compiler is installed.
99-
100-
```shell
101-
g++ --version
102-
```
103-
104-
and it should print,
105-
106-
```shell
107-
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
108-
Copyright (C) 2019 Free Software Foundation, Inc.
109-
This is free software; see the source for copying conditions. There is NO
110-
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
111-
```
112-
113-
In the above output **ubuntu1~20.04** is my version, yours may be different.
114-
115-
**Step 2: Install cmake**
116-
117-
1. Uninstall the default `cmake` version provided by Ubuntu's package manager and configuration by using:
118-
119-
```shell
120-
sudo apt remove --purge --auto-remove cmake
121-
```
122-
123-
OR:
124-
125-
```shell
126-
sudo apt purge --auto-remove cmake
127-
```
128-
129-
This step is crucial if you have a old version of `cmake` installed in your system.
130-
131-
2. Prepare for installation.
132-
133-
```shell
134-
sudo apt update
135-
sudo apt install -y software-properties-common lsb-release
136-
sudo apt clean all
137-
```
138-
139-
3. Obtain a copy of kitware's signing key.
140-
141-
```shell
142-
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
143-
```
144-
145-
4. Add kitware's repository to your sources list for `Ubuntu Focal Fossa (20.04)`, `Ubuntu Bionic Beaver (18.04)` and `Ubuntu Xenial Xerus (16.04)`.
146-
147-
```shell
148-
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
149-
```
150-
151-
5. As an optional step it is recommended that we also install the kitware-archive-keyring package to ensure that Kitware's keyring stays up to date as they rotate their keys.
152-
153-
```shell
154-
sudo apt update
155-
sudo apt install kitware-archive-keyring
156-
sudo rm /etc/apt/trusted.gpg.d/kitware.gpg
157-
```
158-
159-
6. Finally we can update and install the cmake package.
160-
161-
```shell
162-
sudo apt update
163-
sudo apt install cmake
164-
```
26+
A better and more robust version of this library is [`GoogleTest`][_gtest] which is developed and maintained by Google. It is a official Google product and is used by many notable projects.
16527

16628
<div align="right">
16729
<a href="#top">
@@ -179,31 +41,13 @@ Clone the repository.
17941
git clone https://github.com/joshiayush/xtest.git
18042
```
18143

182-
**Build xtest**
183-
184-
Next step is to build `xtest` as a shared library using our build system `cmake`.
185-
186-
```shell
187-
cmake -B build/ -S .
188-
cd build
189-
make install
190-
```
191-
192-
This will build `xtest` library as `libxtest.so` file inside the `build` directory. Now as the next step you have to create a symbolic link of `libxtest.so` in `/usr/lib/` directory,
193-
194-
```shell
195-
sudo ln -s /build/libxtest.so /usr/lib/libxtest.so
196-
```
197-
198-
Now create symbolic link for the header files inside `/usr/include/C++/9` inside `xtest`,
44+
**Install `libxtest`**
19945

20046
```shell
201-
sudo mkdir /usr/include/C++/9/xtest
202-
sudo ln -s /include/** /usr/include/C++/9/xtest
47+
sudo chmod +x ./tools/install_libxtest.sh
48+
./tools/install_libxtest.sh
20349
```
20450

205-
Now you are all set.
206-
20751
**Build samples**
20852

20953
To build samples,
@@ -229,7 +73,7 @@ Now run the `samples`,
22973
</a>
23074
</div>
23175

232-
# Usage
76+
## Usage
23377

23478
Testing a custom function that returns the sqaure of a given number.
23579

@@ -256,8 +100,6 @@ Now compile the file and link the `libxtest.so` file with it:
256100
g++ -lxtest square_test.cc -o square_test
257101
```
258102

259-
For more information on usage see our [wiki](https://github.com/joshiayush/xtest/wiki).
260-
261103
<div align="right">
262104
<a href="#top">
263105

@@ -266,9 +108,7 @@ For more information on usage see our [wiki](https://github.com/joshiayush/xtest
266108
</a>
267109
</div>
268110

269-
# Contribution
270-
271-
Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
111+
## Contribution
272112

273113
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement", "bug", or "documentation". Don't forget to give the project a star! Thanks again!
274114

@@ -282,82 +122,14 @@ Project [**xtest**][_xtest] is hosted on [GitHub][_github]. If you want to contr
282122
</a>
283123
</div>
284124

285-
# License
286-
287-
Distributed under the BSD 3-Clause License. See [`LICENSE`][_xtest_license_f] for more information. Please do not use project [**xtest**][_xtest] if you have any issue with the BSD 3-Clause License.
288-
289-
<div align="right">
290-
<a href="#top">
291-
292-
![Back to top][back_to_top]
293-
294-
</a>
295-
</div>
296-
297-
# Developers
298-
299-
- [**joshiayush**](https://www.github.com/joshiayush)
300-
301-
<a href="https://github.com/joshiayush">
302-
<img src="./images/github.png" alt="Logo" width="40" height="40">
303-
</a>
304-
<a href="https://www.linkedin.com/in/ayush-joshi-3600a01b7/">
305-
<img src="./images/linkedin.png" alt="Logo" width="40" height="40">
306-
</a>
307-
<a href="http://twitter.com/joshiayushjoshi">
308-
<img src="./images/twitter.png" alt="Logo" width="40" height="40">
309-
</a>
310-
<a href="https://stackoverflow.com/users/13910122/ayush">
311-
<img src="./images/stack-overflow.png" alt="Logo" width="40" height="40">
312-
</a>
313-
314-
<!-- Contibutors who have contributed non-trivial changes are encouraged to add their details here. -->
315-
316-
<div align="right">
317-
<a href="#top">
318-
319-
![Back to top][back_to_top]
320-
321-
</a>
322-
</div>
323-
324-
# Acknowledgments
325-
326-
A big thanks goes to the following resources who have helped in the development of project [**xtest**][_xtest].
327-
328-
- [Flaticon](https://www.flaticon.com/)
329-
- [Shields.io](https://shields.io/)
330-
- [Best-README-Template](https://github.com/othneildrew/Best-README-Template)
331-
- [Stack Overflow](https://www.stackoverflow.com)
332-
333-
<div align="right">
334-
<a href="#top">
335-
336-
![Back to top][back_to_top]
337-
338-
</a>
339-
</div>
340-
341125
<!-- Definitions -->
342126

343127
[_gtest]: https://www.github.com/google/googletest
344128
[_xtest]: https://www.github.com/joshiayush/xtest
345129
[_github]: https://www.github.com
346130

347-
<!-- Shields and attached links -->
348-
349-
[xtest_contributors]: https://img.shields.io/github/contributors/joshiayush/xtest?logo=GitHub&style=for-the-badge
350-
[xtest_contributors_url]: https://github.com/joshiayush/xtest/graphs/contributors
351-
[xtest_forks]: https://img.shields.io/github/forks/joshiayush/xtest?logo=GitHub&style=for-the-badge
352-
[xtest_forks_url]: https://github.com/joshiayush/xtest/network/members
353-
[xtest_stars]: https://img.shields.io/github/stars/joshiayush/xtest?logo=GitHub&style=for-the-badge
354-
[xtest_stars_url]: https://github.com/joshiayush/xtest/stargazers
355-
[xtest_issues]: https://img.shields.io/github/issues/joshiayush/xtest?logo=GitHub&style=for-the-badge
356-
[xtest_issues_url]: https://github.com/joshiayush/xtest/issues
357-
[xtest_license]: https://img.shields.io/github/license/joshiayush/xtest?logo=GitHub&style=for-the-badge
358-
[xtest_license_url]: https://github.com/joshiayush/xtest/blob/master/LICENSE
359-
[developer_linkedin]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
360-
[developer_linkedin_url]: https://www.linkedin.com/in/ayush-joshi-3600a01b7/
131+
<!-- Attached links -->
132+
361133
[back_to_top]: https://img.shields.io/badge/-Back%20to%20top-lightgrey
362134

363135
<!-- Files -->

docs/requirements.md

-12
This file was deleted.

images/github.png

-12.8 KB
Binary file not shown.

images/linkedin.png

-11.2 KB
Binary file not shown.

images/stack-overflow.png

-14.8 KB
Binary file not shown.

images/twitter.png

-13.3 KB
Binary file not shown.

tools/install_libxtest.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
echo '################################################'
4+
echo 'Generating build system for xtest in "build/"...'
5+
echo '################################################'
6+
echo ''
7+
8+
cmake -B build/ -S .
9+
10+
echo ''
11+
echo '##########################################'
12+
echo 'Building object code into "libxtest.so"...'
13+
echo '##########################################'
14+
echo ''
15+
16+
cd build
17+
make install
18+
19+
echo ''
20+
echo '##########################################################'
21+
echo 'Linking "./build/libxtest.so" to "/usr/lib/libxtest.so"...'
22+
echo '##########################################################'
23+
echo ''
24+
25+
sudo ln -s ./build/libxtest.so /usr/lib/libxtest.so
26+
27+
echo ''
28+
echo '#####################################################'
29+
echo 'Linking header files to "/usr/include/C++/9/xtest"...'
30+
echo '#####################################################'
31+
echo ''
32+
33+
if [ -d "/usr/include/C++/9/xtest" ]; then
34+
echo '"/usr/include/C++/9/xtest" directory exists!'
35+
else
36+
echo '"/usr/include/C++/9/xtest" directory does not exists!'
37+
echo 'Making directory "/usr/include/C++/9/xtest"...'
38+
sudo mkdir /usr/include/C++/9/xtest
39+
fi
40+
41+
sudo ln -s include/** /usr/include/C++/9/xtest

0 commit comments

Comments
 (0)