diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-05-03 14:38:43 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-03 22:46:28 +0200 |
commit | b24cfd36aeb9c3ebbbb096eb3837629d9b5fb124 (patch) | |
tree | b5e364a7a5b79355aa07c924e10ca8b8ab0f6c36 /Tests | |
parent | e6922c0d4041b2f3ea4eddaf329238403f95a005 (diff) | |
download | serenity-b24cfd36aeb9c3ebbbb096eb3837629d9b5fb124.zip |
Kernel: Demonstrate kernel crash on invalid fcntl
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Kernel/crash-fcntl-invalid-cmd.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Tests/Kernel/crash-fcntl-invalid-cmd.cpp b/Tests/Kernel/crash-fcntl-invalid-cmd.cpp new file mode 100644 index 0000000000..eed491e27b --- /dev/null +++ b/Tests/Kernel/crash-fcntl-invalid-cmd.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020, Ben Wiederhake <BenWiederhake.GitHub@gmx.de> + * 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 <assert.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int main(int, char**) +{ + int rc = fcntl(0, -42); + if (rc != -1) { + printf("FAIL: rc was %d, instead of -1\n", rc); + return 1; + } else if (errno != EINVAL) { + printf("FAIL: errno was %d, instead of EINVAL=%d\n", errno, EINVAL); + return 1; + } else { + printf("PASS\n"); + } + return 0; +} |