builder

package builder
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/builder

commit 0a5ebea5dc1627ccdff0242bdd6dcee383b58a5b
parent 497c023f0313a8eebe8ee63b3cc5678471bbf06a
Author: enerdhil <enerdhil@bob.lan>
Date:   Sat, 21 Jan 2017 17:16:35 +0100

Add(Project base)

Diffstat:
A.gitignore | 41+++++++++++++++++++++++++++++++++++++++++
ALICENSE | 201+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile | 49+++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.md | 137+++++++++++++++++++++++++++++++++----------------------------------------------
Adocs/doxyfile | 364+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main.c | 21+++++++++++++++++++++
Atests/.gdb_history | 3+++
Atests/Makefile | 24++++++++++++++++++++++++
Atests/main.c | 14++++++++++++++
Atests/test.h | 21+++++++++++++++++++++
Atests/test_args.c | 106+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/test_infos.c | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 999 insertions(+), 80 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,41 @@ +# Object files +*.o +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su + +# Test +tests/test + +# Documentation +docs/doxygen_sqlite3.db +docs/html +docs/man diff --git a/LICENSE b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile @@ -0,0 +1,49 @@ +################################# LICENSE #################################### +# Copyright 2016 Morphux # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +NAME= builder +CC = gcc +LIB = -Llib +CFLAGS = -Wall -Wextra -Werror -Wno-unused-result \ + -I inc -I lib/inc \ + -std=c99 -g -O3 \ + -DVERSION="\"$(VERSION)\"" -DMAINTAINER="\"$(MAINTAINER)\"" -DNAME="\"$(NAME)\"" +LFLAGS = -lmorphux +SRCS = $(wildcard src/*.c) +OBJS = $(SRCS:%.c=%.o) +VERSION = +MAINTAINER = Jules HEZARD <hezardj@gmail.com> + +all: $(NAME) + +$(NAME): $(OBJS) + $(CC) $(CFLAGS) $(LIB) $(LFLAGS) $(OBJS) -o $(NAME) + +check: + make -C tests check + +doc: + doxygen docs/doxyfile + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all + +.PHONY: fclean clean all diff --git a/README.md b/README.md @@ -1,89 +1,66 @@ -BUILDER -======= +<p align="center"> +<img src="https://raw.githubusercontent.com/Morphux/Graphic/master/logo/single_penguin.png" /><br /> +</p> +<p align="center"> +<img src="https://img.shields.io/badge/language-c-blue.svg" /> &nbsp; +<img src="https://img.shields.io/badge/license-Apache--2.0-yellow.svg" /> &nbsp; +<a href="https://travis-ci.org/Morphux/lib"><img src="https://travis-ci.org/Morphux/lib.svg?branch=master"/></a> &nbsp; +<a href="https://scan.coverity.com/projects/lib"> + <img alt="Coverity Scan Build Status" + src="https://scan.coverity.com/projects/11517/badge.svg"/> +</a> +<br /> +<h1 align="center" style="border:none">Morphux/lib</h1> +<h6 align="center">Morphux C Development Library</h6> +</p> +<p align="center"> +<a href="#install">Install</a> • <a href="#test">Test</a> • <a href="#use">Use</a> • <a href="#documentation">Documentation</a> +</p> -# What for ? -- Building packages automatically for all architectures supported by Morphux -- Extracting binaries -- Extracting installed files (Configuration) -- Extracting meta information on the package: Build time, size, ... -- Update the Morphux Package Database - -# Solution -- A deamon server listening on local -- This daemon must execute requests asked by a crawler / manually -- This daemon must build the package -- This daemon must extract information about the said package -- This daemon must be able to execute concurrent builds - -# Infrastructure - -## Git server -The git server is used for package development and configuration. -When a maintainer want to release a package, he push the code into a branch -named: +# Install +### Clone the repository ``` -package_name-version +git clone https://github.com/Morphux/lib.git ``` -When this happen, the crawler is trigerred to launch a build. - -## Crawler -When a version of a package is updated (Hotfix) / a new version is pushed, the crawler is -trigerred. He then must launch the build of the package via the BUILDER -and retrieve the informations about that build. -On success, the crawler will update the Morphux Package Database™. -On failure, the result must be stored too, and send to maintainer. - -## Database -The Morphux Package Database™ is the database of all the packages of Morphux. -This database is used by MPM. - -# The Build -In order to build a package, the builder must: -- Launch a VM / Container of Vanilla Morphux (Clean install VM) -- Clone the package source into that env -- Launch the package build by following instructions gived by the maintainer -in the package.json file. -- In order to extract the files / binaries installed by the package, a fakeroot -install must be achieved. -- For the build itself, a modified version of MPM must be called. - -# Extracting informations -The following informations must be retrieved by the builder: -- Compilation times (Just 'make' and all the commands (./configure, make, etc)) -- Installation size (Size after install - Size before install) -- Determine binaries and config files, with path -- Determine wich libraries are static or dynamic -- Make hash for binaries - -# Protocol -This documentation will not cover the entirety of the final protocol, just a -quick overview. +### Compile +``` +make +``` -A Protocol must be defined in order for the different services to talk together. -The protocol of the builder is a simple one, because the actions are limited: +# Test +### Dependencies +``` +valgrind +``` +### Basic Tests +``` +make -C tests check +``` +### Memory Tests +``` +make -C tests valgrind +``` -- Build a package -- Start VM -- Stop VM -- Sanitize -- Launch a new installation on a VM +# Use +Compile with the following options +``` +gcc [...] -Llib/ -lmorphux -Ilib/inc +``` +Of course, ```lib``` directory must exist. -The builder must execute the requested action, and then return a response. -This Protocol can be a Text one, built on top of TCP. +In code: +```C +#include <morphux.h> +``` -# Performance -In order to gain performance, the VMs must be up whenever it's possible. -However, the environment must stay Vanilla, so the builder must clean the installed file -(and the dependencies) after a build. -The builder must force a Sanitize of a VM if required manually, or if the builder -requires it. -In order to Sanitize a VM, a clean Install of Morphux Vanilla must be kept somewhere, -and this install must be copied on the new VM. -The clean install is generated via the associated command, in the protocol. +# Documentation +### Dependencies +``` +doxygen +``` -# Code -- Threading -- All test -- Calling the mpm binary | using the mpm library -- Non blocking sockets +Generate it: +``` +make doc +``` diff --git a/docs/doxyfile b/docs/doxyfile @@ -0,0 +1,364 @@ +# Doxyfile 1.8.8 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = Morphux/lib +PROJECT_NUMBER = +PROJECT_BRIEF = +PROJECT_LOGO = +OUTPUT_DIRECTORY = docs +CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +TCL_SUBST = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +LOOKUP_CACHE_SIZE = 0 +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = src +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.as \ + *.js +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +CLANG_ASSISTED_PARSING = NO +CLANG_OPTIONS = +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = YES +HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = +SEARCHENGINE = NO +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +LATEX_EXTRA_FILES = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = YES +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_SUBDIR = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- +GENERATE_DOCBOOK = NO +DOCBOOK_OUTPUT = docbook +DOCBOOK_PROGRAMLISTING = NO +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +EXTERNAL_PAGES = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +MSCGEN_PATH = +DIA_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +INTERACTIVE_SVG = NO +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES + diff --git a/src/main.c b/src/main.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhezard <jhezard@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/21 17:04:29 by jhezard #+# #+# */ +/* Updated: 2017/01/21 17:09:56 by jhezard ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include <morphux.h> + +int main(int ac, const char *av[]) { + (void)ac; + (void)av; + set_program_name(NAME); + set_version(VERSION); + set_maintainer(MAINTAINER); + return 0; +} diff --git a/tests/.gdb_history b/tests/.gdb_history @@ -0,0 +1,3 @@ +r +bt +q diff --git a/tests/Makefile b/tests/Makefile @@ -0,0 +1,24 @@ +NAME = test +CC = gcc +CFLAGS = -Wall -Wextra -g -O3 -I../inc -lmorphux +SRCS = $(wildcard *.c) +OBJS = $(SRCS:%.c=%.o) + +all: $(NAME) + +$(NAME): $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $(NAME) -L../ -lmorphux + +check: $(NAME) + ./$(NAME) + +valgrind: $(NAME) + valgrind --leak-check=full --error-exitcode=1 ./$(NAME) + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all diff --git a/tests/main.c b/tests/main.c @@ -0,0 +1,14 @@ +#include "test.h" + +int main(void) { + u32_t ret; + + register_infos_tests(); + register_args_tests(); + + m_info("Beginning tests...\n"); + ret = test_all(); + test_free(); + + return ret; +} diff --git a/tests/test.h b/tests/test.h @@ -0,0 +1,21 @@ +#ifndef TEST_H +# define TEST_H + +# include <morphux.h> +# include <unistd.h> +# include <sys/types.h> +# include <sys/wait.h> + +void register_infos_tests(void); +void register_args_tests(void); + +struct margs_tests { + bool opt_q; + bool opt_w; + bool opt_e; + bool opt_r; + bool opt_t; + bool opt_y; +}; + +#endif /* TEST_H */ diff --git a/tests/test_args.c b/tests/test_args.c @@ -0,0 +1,106 @@ +#include "test.h" + +static struct margs_tests args; + +TEST(args_NULL) { + TEST_ASSERT(read_opt(0, NULL, NULL) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_NULL_1) { + TEST_ASSERT(read_opt(10, NULL, NULL) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_NULL_2) { + char *tab[] = {"test", "test2"}; + TEST_ASSERT(read_opt(0, tab, NULL) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_NULL_3) { + char *tab[] = {"test", "test2"}; + TEST_ASSERT(read_opt(10, tab, NULL) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_NULL_4) { + char *tab[] = {"test", "test2"}; + margs_t t; + + TEST_ASSERT(read_opt(0, tab, &t) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_NULL_5) { + margs_t t; + + TEST_ASSERT(read_opt(10, NULL, &t) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_empty_1) { + margs_t t; + char *tab[] = {"", "", ""}; + + TEST_ASSERT(read_opt(3, tab, &t) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + +TEST(args_empty_2) { + margs_t t; + char *tab[] = {NULL, NULL, NULL}; + + TEST_ASSERT(read_opt(3, tab, &t) == 0, "Not handling null arguments"); + return TEST_SUCCESS; +} + + +TEST(args_unhandled_1) { + fflush(stdout); + margs_t opt[] = { + {'z', "--zoiberg", "No idea.", false, NULL}, + ARGS_EOL + }; + char *av[] = {"./tests", "oui", "--allow"}; + pid_t pid; + int st, fd[2]; + + pipe(fd); + + if ((pid = fork()) == 0) { + + dup2(fd[1], 1); + dup2(fd[1], 2); + close(fd[1]); + + TEST_ASSERT(read_opt(sizeof(av), av, opt) == 0, "Not handling properly unknown arguments"); + } else { + pid = waitpid(pid, &st, 0); + close(fd[1]); + TEST_ASSERT((WEXITSTATUS(st) == 1), "Wrong return"); + } + return TEST_SUCCESS; +} + + +void reset_args(void) { + args.opt_q = false; + args.opt_w = false; + args.opt_e = false; + args.opt_r = false; + args.opt_t = false; + args.opt_y = false; +} + +void register_args_tests(void) { + reg_test("m_args", args_NULL); + reg_test("m_args", args_NULL_1); + reg_test("m_args", args_NULL_2); + reg_test("m_args", args_NULL_3); + reg_test("m_args", args_NULL_4); + reg_test("m_args", args_NULL_5); + reg_test("m_args", args_empty_1); + reg_test("m_args", args_empty_2); + reg_test("m_args", args_unhandled_1); +} diff --git a/tests/test_infos.c b/tests/test_infos.c @@ -0,0 +1,98 @@ +#include "test.h" + +TEST(program_name_1) { + TEST_ASSERT((get_program_name() == NULL), "Wrong program name init"); + return TEST_SUCCESS; +} + +TEST(program_name_2) { + set_program_name("Hey !"); + TEST_ASSERT(strcmp(get_program_name(), "Hey !") == 0, "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(program_name_3) { + TEST_ASSERT(strcmp(get_program_name(), "Hey !") == 0, "Wrong program_name return"); + set_program_name("Yo !"); + TEST_ASSERT(strcmp(get_program_name(), "Yo !") == 0, "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(program_name_4) { + TEST_ASSERT(strcmp(get_program_name(), "Yo !") == 0, "Wrong program_name return"); + set_program_name(""); + TEST_ASSERT((get_program_name() == NULL), "Wrong program_name return"); + set_program_name(NULL); + TEST_ASSERT((get_program_name() == NULL), "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(version_1) { + TEST_ASSERT((get_version() == NULL), "Wrong program name init"); + return TEST_SUCCESS; +} + +TEST(version_2) { + set_version("Hey !"); + TEST_ASSERT(strcmp(get_version(), "Hey !") == 0, "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(version_3) { + TEST_ASSERT(strcmp(get_version(), "Hey !") == 0, "Wrong program_name return"); + set_version("Yo !"); + TEST_ASSERT(strcmp(get_version(), "Yo !") == 0, "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(version_4) { + TEST_ASSERT(strcmp(get_version(), "Yo !") == 0, "Wrong program_name return"); + set_version(""); + TEST_ASSERT((get_version() == NULL), "Wrong program_name return"); + set_version(NULL); + TEST_ASSERT((get_version() == NULL), "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(maintainer_1) { + TEST_ASSERT((get_version() == NULL), "Wrong program name init"); + return TEST_SUCCESS; +} + +TEST(maintainer_2) { + set_version("Hey !"); + TEST_ASSERT(strcmp(get_version(), "Hey !") == 0, "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(maintainer_3) { + TEST_ASSERT(strcmp(get_version(), "Hey !") == 0, "Wrong program_name return"); + set_version("Yo !"); + TEST_ASSERT(strcmp(get_version(), "Yo !") == 0, "Wrong program_name return"); + return TEST_SUCCESS; +} + +TEST(maintainer_4) { + TEST_ASSERT(strcmp(get_version(), "Yo !") == 0, "Wrong program_name return"); + set_version(""); + TEST_ASSERT((get_version() == NULL), "Wrong program_name return"); + set_version(NULL); + TEST_ASSERT((get_version() == NULL), "Wrong program_name return"); + return TEST_SUCCESS; +} + + +void register_infos_tests(void) { + reg_test("m_infos", program_name_1); + reg_test("m_infos", program_name_2); + reg_test("m_infos", program_name_3); + reg_test("m_infos", program_name_4); + reg_test("m_infos", version_1); + reg_test("m_infos", version_2); + reg_test("m_infos", version_3); + reg_test("m_infos", version_4); + reg_test("m_infos", maintainer_1); + reg_test("m_infos", maintainer_2); + reg_test("m_infos", maintainer_3); + reg_test("m_infos", maintainer_4); +}