vtest: Unify ident size

Turns out some files managed to have a mix between 2, 3, 4 and tabs for
indenting. The only way to really fix this was to do just a single commit
that fixes all of them.

Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Jakob Bornecrantz 7 years ago
parent 701c9615d4
commit 21ebb9449b
  1. 6
      vtest/util.c
  2. 1
      vtest/util.h
  3. 3
      vtest/vtest.h
  4. 1
      vtest/vtest_protocol.h
  5. 917
      vtest/vtest_renderer.c
  6. 151
      vtest/vtest_server.c

@ -21,12 +21,14 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include "util.h" #include "util.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
int vtest_wait_for_fd_read(int fd) int vtest_wait_for_fd_read(int fd)
{ {
fd_set read_fds; fd_set read_fds;
@ -36,11 +38,13 @@ int vtest_wait_for_fd_read(int fd)
FD_SET(fd, &read_fds); FD_SET(fd, &read_fds);
ret = select(fd + 1, &read_fds, NULL, NULL, NULL); ret = select(fd + 1, &read_fds, NULL, NULL, NULL);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
if (FD_ISSET(fd, &read_fds)) { if (FD_ISSET(fd, &read_fds)) {
return 0; return 0;
} }
return -1; return -1;
} }

@ -21,6 +21,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#ifndef VTEST_UTIL_H #ifndef VTEST_UTIL_H
#define VTEST_UTIL_H #define VTEST_UTIL_H

@ -21,10 +21,12 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#ifndef VTEST_H #ifndef VTEST_H
#define VTEST_H #define VTEST_H
#include <errno.h> #include <errno.h>
int vtest_create_renderer(int in_fd, int out_fd, uint32_t length); int vtest_create_renderer(int in_fd, int out_fd, uint32_t length);
int vtest_send_caps(uint32_t length_dw); int vtest_send_caps(uint32_t length_dw);
@ -49,5 +51,6 @@ int vtest_ping_protocol_version(uint32_t length_dw);
int vtest_protocol_version(uint32_t length_dw); int vtest_protocol_version(uint32_t length_dw);
void vtest_destroy_renderer(void); void vtest_destroy_renderer(void);
#endif #endif

@ -21,6 +21,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#ifndef VTEST_PROTOCOL #ifndef VTEST_PROTOCOL
#define VTEST_PROTOCOL #define VTEST_PROTOCOL

File diff suppressed because it is too large Load Diff

@ -21,6 +21,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <stdbool.h> #include <stdbool.h>
@ -37,54 +38,56 @@
#include "vtest.h" #include "vtest.h"
#include "vtest_protocol.h" #include "vtest_protocol.h"
static int vtest_open_socket(const char *path) static int vtest_open_socket(const char *path)
{ {
struct sockaddr_un un; struct sockaddr_un un;
int sock; int sock;
sock = socket(PF_UNIX, SOCK_STREAM, 0); sock = socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) { if (sock < 0) {
return -1; return -1;
} }
memset(&un, 0, sizeof(un)); memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX; un.sun_family = AF_UNIX;
snprintf(un.sun_path, sizeof(un.sun_path), "%s", path); snprintf(un.sun_path, sizeof(un.sun_path), "%s", path);
unlink(un.sun_path); unlink(un.sun_path);
if (bind(sock, (struct sockaddr *)&un, sizeof(un)) < 0) { if (bind(sock, (struct sockaddr *)&un, sizeof(un)) < 0) {
goto err; goto err;
} }
if (listen(sock, 1) < 0){ if (listen(sock, 1) < 0){
goto err; goto err;
} }
return sock; return sock;
err: err:
close(sock); close(sock);
return -1; return -1;
} }
static int wait_for_socket_accept(int sock) static int wait_for_socket_accept(int sock)
{ {
fd_set read_fds; fd_set read_fds;
int new_fd; int new_fd;
int ret; int ret;
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
FD_SET(sock, &read_fds); FD_SET(sock, &read_fds);
ret = select(sock + 1, &read_fds, NULL, NULL, NULL); ret = select(sock + 1, &read_fds, NULL, NULL, NULL);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
if (FD_ISSET(sock, &read_fds)) {
new_fd = accept(sock, NULL, NULL); if (FD_ISSET(sock, &read_fds)) {
return new_fd; new_fd = accept(sock, NULL, NULL);
} return new_fd;
return -1; }
return -1;
} }
typedef int (*vtest_cmd_fptr_t)(uint32_t); typedef int (*vtest_cmd_fptr_t)(uint32_t);
@ -168,11 +171,11 @@ static int run_renderer(int in_fd, int out_fd)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret, sock = -1, in_fd, out_fd; int ret, sock = -1, in_fd, out_fd;
pid_t pid; pid_t pid;
bool do_fork = true, loop = true; bool do_fork = true, loop = true;
struct sigaction sa; struct sigaction sa;
char *socket_name = VTEST_DEFAULT_SOCKET_NAME; char *socket_name = VTEST_DEFAULT_SOCKET_NAME;
#ifdef __AFL_LOOP #ifdef __AFL_LOOP
while (__AFL_LOOP(1000)) { while (__AFL_LOOP(1000)) {
@ -180,10 +183,10 @@ while (__AFL_LOOP(1000)) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "--no-loop-or-fork")) { if (!strcmp(argv[1], "--no-loop-or-fork")) {
do_fork = false; do_fork = false;
loop = false; loop = false;
} else if (!strcmp(argv[1], "--no-fork")) { } else if (!strcmp(argv[1], "--no-fork")) {
do_fork = false; do_fork = false;
} else { } else {
ret = open(argv[1], O_RDONLY); ret = open(argv[1], O_RDONLY);
if (ret == -1) { if (ret == -1) {
@ -201,48 +204,52 @@ while (__AFL_LOOP(1000)) {
do_fork = false; do_fork = false;
goto start; goto start;
} }
} }
if (do_fork) { if (do_fork) {
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; sa.sa_flags = 0;
if (sigaction(SIGCHLD, &sa, 0) == -1) { if (sigaction(SIGCHLD, &sa, 0) == -1) {
perror(0); perror(0);
exit(1); exit(1);
} }
} }
sock = vtest_open_socket(socket_name); sock = vtest_open_socket(socket_name);
restart: restart:
in_fd = wait_for_socket_accept(sock); in_fd = wait_for_socket_accept(sock);
out_fd = in_fd; out_fd = in_fd;
start: start:
if (do_fork) { if (do_fork) {
/* fork a renderer process */ /* fork a renderer process */
switch ((pid = fork())) { switch ((pid = fork())) {
case 0: case 0:
run_renderer(in_fd, out_fd); run_renderer(in_fd, out_fd);
exit(0); exit(0);
break; break;
case -1: case -1:
default: default:
close(in_fd); close(in_fd);
if (loop) if (loop) {
goto restart; goto restart;
}
} }
} else { } else {
run_renderer(in_fd, out_fd); run_renderer(in_fd, out_fd);
vtest_destroy_renderer(); vtest_destroy_renderer();
if (loop) if (loop) {
goto restart; goto restart;
} }
}
if (sock != -1) if (sock != -1) {
close(sock); close(sock);
if (in_fd != out_fd) }
close(out_fd); if (in_fd != out_fd) {
close(out_fd);
}
#ifdef __AFL_LOOP #ifdef __AFL_LOOP
} }

Loading…
Cancel
Save