diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-08-01 23:49:01 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-02 17:15:36 +0200 |
commit | 58240aedd98041be8d10921cdea0e52f9e13daa6 (patch) | |
tree | 5bb85e1e7dbf37e74e4ea1ca858b825a0e3382fc | |
parent | 29eceebdbf78f94d2993ab476a076a6fe82b4131 (diff) | |
download | serenity-58240aedd98041be8d10921cdea0e52f9e13daa6.zip |
Tests: License headers, clang-format, clearer output
16 files changed, 359 insertions, 30 deletions
diff --git a/Userland/Tests/Kernel/bind-local-socket-to-symlink.cpp b/Userland/Tests/Kernel/bind-local-socket-to-symlink.cpp index 424f02633d..ce4bfc4a3f 100644 --- a/Userland/Tests/Kernel/bind-local-socket-to-symlink.cpp +++ b/Userland/Tests/Kernel/bind-local-socket-to-symlink.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <stdio.h> #include <string.h> #include <sys/socket.h> @@ -24,8 +50,10 @@ int main(int, char**) strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); rc = bind(fd, (struct sockaddr*)(&addr), sizeof(addr)); - if (rc < 0 && errno == EADDRINUSE) + if (rc < 0 && errno == EADDRINUSE) { + printf("PASS\n"); return 0; + } return 1; } diff --git a/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp b/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp index 988860427a..0ffaafa19d 100644 --- a/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp +++ b/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <AK/Types.h> #include <fcntl.h> #include <stdio.h> diff --git a/Userland/Tests/Kernel/elf-execve-mmap-race.cpp b/Userland/Tests/Kernel/elf-execve-mmap-race.cpp index 05fed4f991..714a88f45d 100644 --- a/Userland/Tests/Kernel/elf-execve-mmap-race.cpp +++ b/Userland/Tests/Kernel/elf-execve-mmap-race.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <LibELF/exec_elf.h> #include <fcntl.h> #include <pthread.h> @@ -69,7 +95,7 @@ int main() header.e_entry = 0; - int fd = open("x", O_RDWR | O_CREAT, 0777); + int fd = open("/tmp/x", O_RDWR | O_CREAT, 0777); if (fd < 0) { perror("open"); return 1; @@ -117,7 +143,7 @@ int main() if (!fork()) { try_again: printf("exec\n"); - if (execl("/home/anon/x", "x", nullptr) < 0) { + if (execl("/tmp/x", "x", nullptr) < 0) { } goto try_again; } diff --git a/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp b/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp index 8ef6604eba..3f44b0446d 100644 --- a/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp +++ b/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <LibELF/exec_elf.h> #include <fcntl.h> #include <stdio.h> diff --git a/Userland/Tests/Kernel/mmap-write-into-running-programs-executable-file.cpp b/Userland/Tests/Kernel/mmap-write-into-running-programs-executable-file.cpp index 90a8feeb4e..66127a632a 100644 --- a/Userland/Tests/Kernel/mmap-write-into-running-programs-executable-file.cpp +++ b/Userland/Tests/Kernel/mmap-write-into-running-programs-executable-file.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <AK/Types.h> #include <fcntl.h> #include <stdio.h> diff --git a/Userland/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp b/Userland/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp index fd043ca570..b76c6f7fd1 100644 --- a/Userland/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp +++ b/Userland/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp @@ -24,8 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <pthread.h> #include <assert.h> +#include <pthread.h> #include <signal.h> #include <stdio.h> #include <time.h> diff --git a/Userland/Tests/Kernel/null-deref-close-during-select.cpp b/Userland/Tests/Kernel/null-deref-close-during-select.cpp index 907c650616..97d8aba41e 100644 --- a/Userland/Tests/Kernel/null-deref-close-during-select.cpp +++ b/Userland/Tests/Kernel/null-deref-close-during-select.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <pthread.h> #include <stdio.h> #include <sys/select.h> diff --git a/Userland/Tests/Kernel/null-deref-crash-during-pthread_join.cpp b/Userland/Tests/Kernel/null-deref-crash-during-pthread_join.cpp index 409cbe90f3..65bafa4096 100644 --- a/Userland/Tests/Kernel/null-deref-crash-during-pthread_join.cpp +++ b/Userland/Tests/Kernel/null-deref-crash-during-pthread_join.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <pthread.h> #include <stdio.h> #include <sys/select.h> diff --git a/Userland/Tests/Kernel/path-resolution-race.cpp b/Userland/Tests/Kernel/path-resolution-race.cpp index 804fbc1b52..c601f90a37 100644 --- a/Userland/Tests/Kernel/path-resolution-race.cpp +++ b/Userland/Tests/Kernel/path-resolution-race.cpp @@ -1,5 +1,31 @@ -#include <unistd.h> +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <sys/stat.h> +#include <unistd.h> int main() { diff --git a/Userland/Tests/Kernel/pledge-test-failures.cpp b/Userland/Tests/Kernel/pledge-test-failures.cpp index 38c6742a07..ee73a711e5 100644 --- a/Userland/Tests/Kernel/pledge-test-failures.cpp +++ b/Userland/Tests/Kernel/pledge-test-failures.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <stdio.h> #include <unistd.h> @@ -21,5 +47,6 @@ int main() return 1; } + printf("PASS\n"); return 0; } diff --git a/Userland/Tests/Kernel/pthread-cond-timedwait-example.cpp b/Userland/Tests/Kernel/pthread-cond-timedwait-example.cpp index 2a5e2109c0..cdae03cbd2 100644 --- a/Userland/Tests/Kernel/pthread-cond-timedwait-example.cpp +++ b/Userland/Tests/Kernel/pthread-cond-timedwait-example.cpp @@ -1,25 +1,50 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <cassert> +#include <cstring> +#include <ctime> +#include <errno.h> +#include <pthread.h> #include <stdio.h> #include <stdlib.h> -#include <pthread.h> -#include <errno.h> #include <unistd.h> -#include <ctime> -#include <cstring> -#include <cassert> -struct worker_t -{ - const char* name; - int count; - pthread_t thread; +struct worker_t { + const char* name; + int count; + pthread_t thread; pthread_mutex_t lock; - pthread_cond_t cond; - long int wait_time; + pthread_cond_t cond; + long int wait_time; }; void* run_worker(void* args) { - struct timespec time_to_wait = {0, 0}; + struct timespec time_to_wait = { 0, 0 }; worker_t* worker = (worker_t*)args; worker->count = 0; @@ -51,7 +76,7 @@ void init_worker(worker_t* worker, const char* name, long int wait_time) pthread_mutex_init(&worker->lock, nullptr); pthread_cond_init(&worker->cond, nullptr); - pthread_create(&worker->thread, &attr, &run_worker, (void*) worker); + pthread_create(&worker->thread, &attr, &run_worker, (void*)worker); pthread_attr_destroy(&attr); } diff --git a/Userland/Tests/Kernel/uaf-close-while-blocked-in-read.cpp b/Userland/Tests/Kernel/uaf-close-while-blocked-in-read.cpp index b75e0bbbaa..03a726678e 100644 --- a/Userland/Tests/Kernel/uaf-close-while-blocked-in-read.cpp +++ b/Userland/Tests/Kernel/uaf-close-while-blocked-in-read.cpp @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include <pthread.h> #include <stdio.h> #include <string.h> @@ -23,8 +49,13 @@ int main(int, char**) printf("First thread doing a blocking read from pipe...\n"); char buffer[16]; - int nread = read(pipefds[0], buffer, sizeof(buffer)); - printf("Ok, read %d bytes from pipe\n", nread); + ssize_t nread = read(pipefds[0], buffer, sizeof(buffer)); + if (nread != 0) { + printf("FAIL, read %zd bytes from pipe\n", nread); + return 1; + } + + printf("PASS\n"); return 0; } diff --git a/Userland/Tests/LibC/accuracy-strtod.cpp b/Userland/Tests/LibC/accuracy-strtod.cpp index b5cb8d77cc..881d792794 100644 --- a/Userland/Tests/LibC/accuracy-strtod.cpp +++ b/Userland/Tests/LibC/accuracy-strtod.cpp @@ -38,6 +38,7 @@ static const char* TEXT_ERROR = "\x1b[01;35m"; static const char* TEXT_WRONG = "\x1b[01;31m"; static const char* TEXT_OFBY1 = "\x1b[01;97m"; static const char* TEXT_RESET = "\x1b[0m"; +static const long long LENIENCY = 8; struct Testcase { const char* test_name; @@ -307,7 +308,7 @@ bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, const char* long long actual_ll = cast_ll(readable.as_double); long long off_by = expect_ll - actual_ll; - bool ofby1_hex = off_by != 0 && -8 <= off_by && off_by <= 8; + bool ofby1_hex = off_by != 0 && -LENIENCY <= off_by && off_by <= LENIENCY; bool wrong_hex = !ofby1_hex && strcmp(expect_hex, actual_hex) != 0; bool error_cns = !actual_consume_possible; bool wrong_cns = !error_cns && (actual_consume != expect_consume); @@ -374,5 +375,11 @@ int main() } } printf("Out of %lu tests, saw %d successes and %d fails.\n", NUM_TESTCASES, successes, fails); + if (fails != 0) { + printf("FAIL\n"); + return 1; + } + + printf("PASS (with leniency up to %lld ULP from the exact solution.\n", LENIENCY); return 0; } diff --git a/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp b/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp index 57a023a6df..fc74e771fb 100644 --- a/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp +++ b/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp @@ -1,6 +1,32 @@ +/* + * Copyright (c) 2018-2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <fcntl.h> #include <stdio.h> #include <unistd.h> -#include <fcntl.h> int main() { diff --git a/Userland/Tests/LibC/memmem-tests.cpp b/Userland/Tests/LibC/memmem-tests.cpp index 87487fcf2c..c8613bbb68 100644 --- a/Userland/Tests/LibC/memmem-tests.cpp +++ b/Userland/Tests/LibC/memmem-tests.cpp @@ -66,5 +66,6 @@ int main() ++i; } + printf(failed ? "FAIL\n" : "PASS\n"); return failed ? 1 : 0; } diff --git a/Userland/Tests/LibC/qsort-sorts-and-copies.cpp b/Userland/Tests/LibC/qsort-sorts-and-copies.cpp index c7ded6a78a..0788ae5e9d 100644 --- a/Userland/Tests/LibC/qsort-sorts-and-copies.cpp +++ b/Userland/Tests/LibC/qsort-sorts-and-copies.cpp @@ -37,7 +37,8 @@ struct SortableObject { int m_payload; }; -int compare_sortable_object(const void* a, const void* b) { +int compare_sortable_object(const void* a, const void* b) +{ const int key1 = static_cast<const SortableObject*>(a)->m_key; const int key2 = static_cast<const SortableObject*>(b)->m_key; if (key1 < key2) { @@ -49,12 +50,13 @@ int compare_sortable_object(const void* a, const void* b) { } } -int calc_payload_for_pos(size_t pos) { +int calc_payload_for_pos(size_t pos) +{ pos *= 231; return pos ^ (pos << 8) ^ (pos << 16) ^ (pos << 24); } -void shuffle_vec(Vector<SortableObject> &test_objects) +void shuffle_vec(Vector<SortableObject>& test_objects) { for (size_t i = 0; i < test_objects.size() * 3; ++i) { auto i1 = rand() % test_objects.size(); @@ -68,7 +70,7 @@ int main() // Generate vector of SortableObjects in sorted order, with payloads determined by their sorted positions Vector<SortableObject> test_objects; for (auto i = 0; i < 1024; ++i) { - test_objects.append({i * 137, calc_payload_for_pos(i)}); + test_objects.append({ i * 137, calc_payload_for_pos(i) }); } for (size_t i = 0; i < NUM_RUNS; i++) { // Shuffle the vector, then sort it again @@ -76,8 +78,8 @@ int main() qsort(test_objects.data(), test_objects.size(), sizeof(SortableObject), compare_sortable_object); // Check that the objects are sorted by key for (auto i = 0u; i + 1 < test_objects.size(); ++i) { - const auto &key1 = test_objects[i].m_key; - const auto &key2 = test_objects[i + 1].m_key; + const auto& key1 = test_objects[i].m_key; + const auto& key2 = test_objects[i + 1].m_key; if (key1 > key2) { printf("\x1b[01;35mTests failed: saw key %d before key %d\n", key1, key2); return 1; @@ -93,6 +95,6 @@ int main() } } } - printf("Tests succeeded\n"); + printf("PASS\n"); return 0; } |