Browse Source

Tasks script is part of fish config now

Kajetan Johannes Hammerle 2 weeks ago
parent
commit
5982cd1e96
3 changed files with 22 additions and 196 deletions
  1. 0 190
      tasks
  2. 11 5
      test/Main.c
  3. 11 1
      valgrind.supp

+ 0 - 190
tasks

@@ -1,190 +0,0 @@
-#!/bin/bash
-set -e
-clear
-cd $(dirname $0)
-
-compiler="gcc"
-if [ -e compiler ]; then
-    compiler=$(cat compiler)
-    echo "compiling with $compiler"
-fi
-
-printHelpExit() {
-    echo "$0 clean           | remove build results"
-    echo "$0 build <type>    | build everything"
-    echo "$0 install         | move build results into the install folder"
-    echo "$0 test <type>     | run the tests"
-    echo "$0 valgrind <type> | run the tests with valgrind"
-    echo "$0 coverage        | generate code coverage"
-    echo "$0 time            | check build time"
-    exit 0
-}
-
-task=$1
-if [ -z "$task" ]; then
-    printHelpExit
-fi
-
-# task vars
-build_debug=false
-build_profile=false
-build_release=false
-
-test_debug=false
-test_release=false
-
-valgrind=""
-time=false
-install=false
-coverage=false
-testArgs="test"
-
-export CMAKE_EXPORT_COMPILE_COMMANDS=true
-
-# parsing
-if [ "$task" = "clean" ]; then
-    rm -rf build_debug build_profile build_release install
-elif [ "$task" = "build" ]; then
-    type=$2
-    if [ "$type" = "debug" ]; then
-        build_debug=true
-    elif [ "$type" = "release" ]; then
-        build_release=true
-    elif [ "$type" = "all" ]; then
-        build_debug=true
-        build_release=true
-    else
-        echo "Valid build types are: debug, release, all"
-        printHelpExit
-    fi
-elif [ "$task" = "install" ]; then
-    build_release=true
-    install=true
-elif [ "$task" = "coverage" ]; then
-    build_debug=true
-    test_debug=true
-    coverage=true
-elif [ "$task" = "test" ]; then
-    type=$2
-    if [ "$type" = "debug" ]; then
-        build_debug=true
-        test_debug=true
-    elif [ "$type" = "release" ]; then
-        build_release=true
-        test_release=true
-    elif [ "$type" = "window" ]; then
-        build_debug=true
-        test_debug=true
-        testArgs="window"
-    elif [ "$type" = "all" ]; then
-        build_debug=true
-        test_debug=true
-        build_release=true
-        test_release=true
-    else
-        echo "Valid test types are: debug, release, window, all"
-        printHelpExit
-    fi
-elif [ "$task" = "valgrind" ]; then
-    type=$2
-    if [ "$type" = "debug" ]; then
-        build_debug=true
-        test_debug=true
-    elif [ "$type" = "release" ]; then
-        build_release=true
-        test_release=true
-    elif [ "$type" = "window" ]; then
-        build_debug=true
-        test_debug=true
-        testArgs="window"
-    elif [ "$type" = "all" ]; then
-        build_debug=true
-        test_debug=true
-        build_release=true
-        test_release=true
-    else
-        echo "Valid valgrind types are: debug, release, window, all"
-        printHelpExit
-    fi
-    valgrind="valgrind \
-        --leak-check=full \
-        --show-leak-kinds=all \
-        --suppressions=../valgrind.supp
-        "
-elif [ "$task" = "time" ]; then
-    build_release=true
-    time=true
-else
-    echo "unknown task"
-    printHelpExit
-fi
-
-# task execution
-buildProfile() {
-    folder=$1
-    shift 1
-    if [ ! -e "$folder" ]; then
-        cmake -B "$folder" -S . -G Ninja -DCMAKE_C_COMPILER=${compiler} -DCMAKE_INSTALL_PREFIX=../install $@
-    fi
-    ninja -C "$folder"
-}
-
-if $build_debug; then
-    buildProfile build_debug -DCMAKE_BUILD_TYPE=Debug
-fi
-if $build_profile; then
-    buildProfile build_profile -DCMAKE_BUILD_TYPE=RelWithDebInfo
-fi
-if $build_release; then
-    buildProfile build_release -DCMAKE_BUILD_TYPE=Release
-fi
-if $install; then
-    ninja -C build_release install
-fi
-
-function runTests() {
-    LLVM_PROFILE_FILE="default.profraw" $valgrind ./test ../test/resources $testArgs || true
-}
-
-if $test_debug; then
-    cd build_debug
-    runTests
-    cd ..
-fi
-if $test_release; then
-    cd build_release
-    runTests
-    cd ..
-fi
-if $time; then
-    lines=$(cat build_release/.ninja_log | grep "^[0-9]")
-
-    startMillis=0
-    endMillis=0
-    name=""
-    i=0
-    output=""
-    for arg in $lines; do
-        if [ $i == 0 ]; then
-            startMillis=$arg
-        elif [ $i == 1 ]; then
-            endMillis=$arg
-        elif [ $i == 3 ]; then
-            name=$arg
-            diff=$(expr $endMillis - $startMillis)
-            output="${output}\n$diff $name"
-        fi
-        i=$(expr $(expr $i + 1) % 5) && true
-    done
-    printf "$output" | sort -n
-fi
-if $coverage; then
-    if [ $compiler = "gcc" ]; then
-        gcovr -r . build_debug -e test -e performance \
-            --exclude-lines-by-pattern ".*CoverageIgnore.*"
-    else
-        files=$(find build_debug -name *.profraw)
-        llvm-profdata-17 merge -sparse $files -o build_debug/default.profdata
-        llvm-cov-17 show ./build_debug/test -instr-profile=build_debug/default.profdata --ignore-filename-regex="(test/)|(WindowManager.c)" -line-coverage-lt=100
-    fi
-fi

+ 11 - 5
test/Main.c

@@ -1,19 +1,25 @@
 #include <core/Logger.h>
 #include <core/Utility.h>
 #include <locale.h>
+#include <stdio.h>
 #include <string.h>
 
 #include "Tests.h"
 
 int main(int argAmount, char** args) {
+    if(argAmount >= 2 && strcmp(args[1], "help") == 0) {
+        puts("test");
+        puts("window");
+        return 0;
+    }
     setlocale(LC_ALL, "en_US.utf8");
-    if(argAmount < 3) {
-        LOG_ERROR("missing path to images and/or mode");
+    if(argAmount < 2) {
+        LOG_ERROR("missing mode");
         return 0;
-    } else if(strcmp("test", args[2]) == 0) {
-        testImageReader(args[1]);
+    } else if(strcmp("test", args[1]) == 0) {
+        testImageReader("test/resources");
         testNetwork();
-    } else if(strcmp("window", args[2]) == 0) {
+    } else if(strcmp("window", args[1]) == 0) {
         testWindow();
     }
     finalizeTests();

+ 11 - 1
valgrind.supp

@@ -1,3 +1,13 @@
+{
+  LLVM
+  Memcheck:Leak
+  match-leak-kinds: reachable
+  fun:malloc
+  fun:strdup
+  fun:parseAndSetFilename
+  fun:__llvm_profile_initialize
+  ...
+}
 {
   glfwInit 1
   Memcheck:Leak
@@ -102,7 +112,7 @@
   libharfbuzz font stuff
   Memcheck:Leak
   ...
-  obj:/usr/lib/x86_64-linux-gnu/libharfbuzz.so.0.60900.0
+  obj:/usr/lib/x86_64-linux-gnu/libharfbuzz.so.0.61001.0
 }
 {
   libfreetype font stuff