L4Re/departure

dstest_server.cc

10:54182479d4bd
2021-02-01 Paul Boddie Made the opener, opener context and file pager resources, introducing the resource server functionality as a wrapper around server configurations. Introduced testing of the opener-related abstractions.
     1 /*     2  * Test dataspace operations.     3  *     4  * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>     5  *     6  * This program is free software; you can redistribute it and/or     7  * modify it under the terms of the GNU General Public License as     8  * published by the Free Software Foundation; either version 2 of     9  * the License, or (at your option) any later version.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program; if not, write to the Free Software    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    19  * Boston, MA  02110-1301, USA    20  */    21     22 #include <l4/re/env.h>    23 #include <l4/sys/err.h>    24     25 #include <stdio.h>    26 #include <string.h>    27 #include <stdlib.h>    28     29 #include "accessing.h"    30 #include "memory.h"    31 #include "memory_utils.h"    32 #include "pages.h"    33 #include "paging.h"    34 #include "resource_server.h"    35 #include "test_file_opener.h"    36     37     38     39 const unsigned int MEMORY_PAGES = 10;    40 const unsigned int FILE_PAGES = 20;    41     42 int main(void)    43 {    44   /* Some memory plus infrastructure. */    45     46   Memory mem(MEMORY_PAGES);    47   Accessing accessing;    48   Paging paging;    49   Pages pages(&mem);    50   TestFileOpener opener(&accessing, &paging, &pages, page(FILE_PAGES));    51     52   /* Register a server associating it with the given object. */    53     54   ResourceServer server(&opener);    55   long err = server.bind("server");    56     57   if (err)    58   {    59     printf("Could not bind server: %s\n", l4sys_errtostr(err));    60     return 1;    61   }    62     63   printf("Starting server...\n");    64   server.start();    65   return 0;    66 }