-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
129 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
// Copyright (c) Yuxuan Shui <[email protected]> | ||
#pragma once | ||
#include <ctype.h> | ||
#include <math.h> | ||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <string.h> | ||
|
||
#include "compiler.h" | ||
#include "utils.h" | ||
|
||
#define mstrncmp(s1, s2) strncmp((s1), (s2), strlen(s1)) | ||
|
||
|
@@ -38,6 +39,24 @@ static inline int uitostr(unsigned int n, char *buf) { | |
return ret; | ||
} | ||
|
||
/// Convert a double into a string. Avoid using *printf functions to print floating points | ||
/// directly because they are locale dependent. | ||
static inline void dtostr(double n, char **buf) { | ||
BUG_ON(safe_isnan(n)); | ||
BUG_ON(safe_isinf(n)); | ||
if (fabs(n) > 1e9) { | ||
// The number is so big that it's not meaningful to keep decimal places. | ||
asprintf(buf, "%.0f", n); | ||
return; | ||
} | ||
|
||
if (n > 0) { | ||
asprintf(buf, "%.0f.%03d", floor(n), (int)(fmod(n, 1) * 1000)); | ||
} else { | ||
asprintf(buf, "-%.0f.%03d", floor(-n), (int)(fmod(-n, 1) * 1000)); | ||
} | ||
} | ||
|
||
static inline const char *skip_space_const(const char *src) { | ||
if (!src) { | ||
return NULL; | ||
|
@@ -70,4 +89,5 @@ static inline bool starts_with(const char *str, const char *needle, bool ignore_ | |
|
||
/// Similar to `asprintf`, but it reuses the allocated memory pointed to by `*strp`, and | ||
/// reallocates it if it's not big enough. | ||
int asnprintf(char **strp, size_t *capacity, const char *fmt, ...); | ||
int asnprintf(char **strp, size_t *capacity, const char *fmt, ...) | ||
__attribute__((format(printf, 3, 4))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
set -xe | ||
if [ -z $DISPLAY ]; then | ||
exec xvfb-run -s "+extension composite" -a $0 $1 $2 $3 | ||
fi | ||
|
||
echo "Running test $2" | ||
|
||
# TODO keep the log file, and parse it to see if test is successful | ||
($1 --dbus --backend dummy --log-level=debug --log-file=$PWD/log --config=$2) & | ||
main_pid=$! | ||
$3 | ||
picom_exe=$1 | ||
config=$2 | ||
test_script=$3 | ||
|
||
kill -INT $main_pid || true | ||
cat log | ||
rm log | ||
wait $main_pid | ||
function test_with_backend() { | ||
backend=$1 | ||
# TODO keep the log file, and parse it to see if test is successful | ||
($picom_exe --dbus --backend $backend --log-level=debug --log-file=$PWD/log --config=$config) & | ||
main_pid=$! | ||
$test_script | ||
|
||
kill -INT $main_pid || true | ||
cat log | ||
rm log | ||
wait $main_pid | ||
} | ||
|
||
test_with_backend dummy | ||
test_with_backend xrender | ||
test_with_backend glx | ||
# test_with_backend egl | ||
|