l4-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libl4 test cases


From: Matthieu Lemerre
Subject: Re: libl4 test cases
Date: Fri, 11 Feb 2005 19:52:27 +0000
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

Hi,

Here's a patch which adds support for reading/writing things in the
utcb. Along is a C file which tests the loading / storing of MRs/BRs.

Now everyone should be able to test messaging functions in libl4, and
I'll soon add a C file which will test some of the functions of ipc.h.


Thanks,
Matthieu

Attachment: patch
Description: Binary data

/* t-message.c - A test for the interfaces to the L4 message registers.
   Copyright (C) 2005 Free Software Foundation, Inc.
   Written by Matthieu Lemerre <address@hidden>.

   This file is part of the GNU L4 library.
 
   The GNU L4 library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public License
   as published by the Free Software Foundation; either version 2.1 of
   the License, or (at your option) any later version.
 
   The GNU L4 library is distributed in the hope that it will be
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.
 
   You should have received a copy of the GNU Lesser General Public
   License along with the GNU L4 library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.  */

#include <string.h>
#include <stddef.h>

/* This must be included before anything else.  */
#include "environment.h"


#include <l4/message.h>

void
test_mrs (void)
{
  _L4_word_t word;
  _L4_word_t words[3] = {1, 2 , 3};
  _L4_word_t test_word = 22;
  _L4_word_t test_words[3];

    _L4_load_mr (0, test_word);
    _L4_store_mr (0, &word);
    check_nr ("[intern]", "_L4_load_mr and _L4_store_mr with 
MR0",test_word,word);

    test_word = 23;
    _L4_load_mr (63, test_word);
    _L4_store_mr (63, &word);
    check_nr ("[intern]", "_L4_load_mr and _L4_store_mr with 
MR63",test_word,word);

    _L4_load_mrs (5, 3, words);
    _L4_store_mrs (5, 3, test_words);
    check ("[intern]", "_L4_load_mrs and _L4_store_mrs", ((words[0] == 
test_words[0])
                                               && (words[1] == test_words[1]) 
                                               && (words[2] == test_words[2])),
           "_L4_load_mrs (5, 3, words);\n"
           "_L4_store_mrs (5, 3 ,test_words);\n"
           "words = {%d, %d, %d} != test_words = {%d, %d, %d}; ",
           words[0], words[1], words[2], test_words[0], test_words[1], 
test_words[2]);

  
#ifdef _L4_INTERFACE_GNU
  {
    
    l4_load_mr (0, test_word);
    l4_store_mr (0, &word);
    check_nr ("[GNU]", "l4_load_mr and l4_store_mr with MR0",test_word,word);

    test_word = 23;
    l4_load_mr (63, test_word);
    l4_store_mr (63, &word);
    check_nr ("[GNU]", "l4_load_mr and l4_store_mr with MR63",test_word,word);

    l4_load_mrs (5, 3, words);
    l4_store_mrs (5, 3, test_words);
    check ("[GNU]", "l4_load_mrs and l4_store_mrs", ((words[0] == test_words[0])
                                               && (words[1] == test_words[1]) 
                                               && (words[2] == test_words[2])),
           "l4_load_mrs (5, 3, words);\n"
           "l4_store_mrs (5, 3 ,test_words);\n"
           "words = {%d, %d, %d} != test_words = {%d, %d, %d}; ",
           words[0], words[1], words[2], test_words[0], test_words[1], 
test_words[2]);
  }
#endif

#ifdef _L4_INTERFACE_L4
  {
    
    L4_LoadMR (0, test_word);
    L4_StoreMR (0, &word);
    check_nr ("[L4]", "L4_LoadMR and L4_StoreMR with MR0",test_word,word);

    test_word = 23;
    L4_LoadMR (63, test_word);
    L4_StoreMR (63, &word);
    check_nr ("[L4]", "L4_LoadMR and L4_StoreMR with MR63",test_word,word);

    L4_LoadMRs (5, 3, words);
    L4_StoreMRs (5, 3, test_words);
    check ("[L4]", "L4_LoadMRs and L4_StoreMRs", ((words[0] == test_words[0])
                                               && (words[1] == test_words[1]) 
                                               && (words[2] == test_words[2])),
           "L4_LoadMRs (5, 3, words);\n"
           "L4_StoreMRs (5, 3 ,test_words);\n"
           "words = {%d, %d, %d} != test_words = {%d, %d, %d}; ",
           words[0], words[1], words[2], test_words[0], test_words[1], 
test_words[2]);
  }
#endif

}


void
test_brs (void)
{
  _L4_word_t word;
  _L4_word_t words[3] = {4, 5, 6};
  _L4_word_t test_word = 24;
  _L4_word_t test_words[3];
  
  _L4_load_br (0, test_word);
  _L4_store_br (0, &word);
  check_nr ("[intern]", "_L4_load_br and _L4_store_br with BR0",test_word,word);
  
  test_word = 23;
  _L4_load_br (63, test_word);
  _L4_store_br (63, &word);
  check_nr ("[intern]", "_L4_load_br and _L4_store_br with 
BR63",test_word,word);
  
  _L4_load_brs (5, 3, words);
  _L4_store_brs (5, 3, test_words);
  check ("[intern]", "_L4_load_brs and _L4_store_brs", ((words[0] == 
test_words[0])
                                                        && (words[1] == 
test_words[1]) 
                                                        && (words[2] == 
test_words[2])),
         "_L4_load_brs (5, 3, words);\n"
         "_L4_store_brs (5, 3 ,test_words);\n"
         "words = {%d, %d, %d} != test_words = {%d, %d, %d}; ",
         words[0], words[1], words[2], test_words[0], test_words[1], 
test_words[2]);

  

#ifdef _L4_INTERFACE_GNU
  {
    
    l4_load_br (0, test_word);
    l4_store_br (0, &word);
    check_nr ("[GNU]", "l4_load_br and l4_store_br with BR0",test_word,word);

    test_word = 23;
    l4_load_br (63, test_word);
    l4_store_br (63, &word);
    check_nr ("[GNU]", "l4_load_br and l4_store_br with BR63",test_word,word);

    l4_load_brs (5, 3, words);
    l4_store_brs (5, 3, test_words);
    check ("[GNU]", "l4_load_brs and l4_store_brs", ((words[0] == test_words[0])
                                               && (words[1] == test_words[1]) 
                                               && (words[2] == test_words[2])),
           "l4_load_brs (5, 3, words);\n"
           "l4_store_brs (5, 3 ,test_words);\n"
           "words = {%d, %d, %d} != test_words = {%d, %d, %d}; ",
           words[0], words[1], words[2], test_words[0], test_words[1], 
test_words[2]);
  }
#endif

#ifdef _L4_INTERFACE_L4
  {
    
    L4_LoadBR (0, test_word);
    L4_StoreBR (0, &word);
    check_nr ("[L4]", "L4_LoadBR and L4_StoreBR with BR0",test_word,word);

    test_word = 23;
    L4_LoadBR (63, test_word);
    L4_StoreBR (63, &word);
    check_nr ("[L4]", "L4_LoadBR and L4_StoreBR with BR63",test_word,word);

    L4_LoadBRs (5, 3, words);
    L4_StoreBRs (5, 3, test_words);
    check ("[L4]", "L4_LoadBRs and L4_StoreBRs", ((words[0] == test_words[0])
                                               && (words[1] == test_words[1]) 
                                               && (words[2] == test_words[2])),
           "L4_LoadBRs (5, 3, words);\n"
           "L4_StoreBRs (5, 3 ,test_words);\n"
           "words = {%d, %d, %d} != test_words = {%d, %d, %d}; ",
           words[0], words[1], words[2], test_words[0], test_words[1], 
test_words[2]);
  }
#endif

}



void
test (void)
{
  test_mrs ();
  test_brs ();
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]