home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / io / description / debug14.c < prev    next >
C/C++ Source or Header  |  2005-07-07  |  4KB  |  178 lines

  1. /*
  2.  * (C) 2002 Clemson University.
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */       
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <pvfs2-types.h>
  10. #include <gossip.h>
  11. #include <pvfs2-debug.h>
  12.  
  13. #include <pint-distribution.h>
  14. #include <pint-dist-utils.h>
  15. #include <pvfs2-request.h>
  16. #include <pint-request.h>
  17.  
  18. #include "debug.h"
  19.  
  20. #define SEGMAX 16
  21. #define BYTEMAX (4*1024*1024)
  22.  
  23. PVFS_offset exp1_offset[] =
  24. {
  25.     0,
  26.     720,
  27.     970
  28. };
  29.  
  30. PVFS_size exp1_size[] =
  31. {
  32.     220,
  33.     180,
  34.     40
  35. };
  36.  
  37. PINT_Request_result expected[] =
  38. {{
  39.     offset_array : &exp1_offset[0],
  40.     size_array : &exp1_size[0],
  41.     segmax : SEGMAX,
  42.     segs : 1,
  43.     bytes : 220
  44. }, {
  45.     offset_array : &exp1_offset[1],
  46.     size_array : &exp1_size[1],
  47.     segmax : SEGMAX,
  48.     segs : 2,
  49.     bytes : 220
  50. }};
  51.  
  52. int request_debug(void)
  53. {
  54.     int i;
  55.     PINT_Request *r1;
  56.     PINT_Request *r2;
  57.     PINT_Request_state *rs1;
  58.     PINT_Request_state *rs2;
  59.     PINT_request_file_data rf1;
  60.     PINT_Request_result seg1;
  61.     static int32_t blen[2] = {20, 200};
  62.     static PVFS_offset disp[2] = {10, 100};
  63.  
  64.     /* PVFS_Process_request arguments */
  65.     int retval;
  66.  
  67.     /* set up request state */
  68.     PVFS_Request_hindexed(2, blen, disp, PVFS_BYTE, &r1);
  69.     rs1 = PINT_new_request_state(r1);
  70.  
  71.     /* set up memory request */
  72.     PVFS_Request_contiguous(220, PVFS_BYTE, &r2);
  73.     rs2 = PINT_new_request_state(r2);
  74.  
  75.     /* set up file data for request */
  76.     PINT_dist_initialize(NULL);
  77.     rf1.server_nr = 0;
  78.     rf1.server_ct = 4;
  79.     rf1.fsize = 6000;
  80.     rf1.dist = PINT_dist_create("simple_stripe");
  81.     rf1.extend_flag = 0;
  82.     PINT_dist_lookup(rf1.dist);
  83.  
  84.     /* set up result struct */
  85.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  86.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  87.     seg1.bytemax = BYTEMAX;
  88.     seg1.segmax = SEGMAX;
  89.     seg1.bytes = 0;
  90.     seg1.segs = 0;
  91.     
  92.     /* skip into the file datatype */
  93.     PINT_REQUEST_STATE_SET_TARGET(rs1, 500);
  94.     PINT_REQUEST_STATE_SET_FINAL(rs1,720);
  95.  
  96.    /* Turn on debugging */
  97.     if (gossipflag)
  98.     {
  99.         gossip_enable_stderr();
  100.         gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG); 
  101.     }
  102.  
  103.     i = 0;
  104.  
  105.     /* skipping logical bytes */
  106.     // PINT_REQUEST_STATE_SET_TARGET(rs1,(3 * 1024) + 512);
  107.     // PINT_REQUEST_STATE_SET_FINAL(rs1,(6 * 1024) + 512);
  108.     
  109.     printf("\n************************************\n");
  110.     printf("1 request in CLIENT mode server 0 of 4\n");
  111.     printf("indexed request type, contig memory type\n");
  112.     printf("offset 500 size 220\n");
  113.     printf("************************************\n");
  114.     do
  115.     {
  116.         PINT_REQUEST_STATE_RESET(rs1);
  117.         PINT_REQUEST_STATE_RESET(rs2);
  118.         seg1.bytes = 0;
  119.         seg1.segs = 0;
  120.  
  121.         /* process request */
  122.         retval = PINT_process_request(rs1, rs2, &rf1, &seg1, PINT_CLIENT);
  123.  
  124.         if(retval >= 0)
  125.         {
  126.             prtseg(&seg1,"Results obtained");
  127.             prtseg(&expected[i],"Results expected");
  128.             cmpseg(&seg1,&expected[i]);
  129.         }
  130.  
  131.         i++;
  132.  
  133.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0);
  134.     
  135.     if(retval < 0)
  136.     {
  137.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  138.         return(-1);
  139.     }
  140.     if(PINT_REQUEST_DONE(rs1))
  141.     {
  142.         printf("**** request done.\n");
  143.     }
  144.     
  145.     printf("\n************************************\n");
  146.     do
  147.     {
  148.         PINT_REQUEST_STATE_RESET(rs1);
  149.         seg1.bytes = 0;
  150.         seg1.segs = 0;
  151.  
  152.         /* process request */
  153.         retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_SERVER);
  154.  
  155.         if(retval >= 0)
  156.         {
  157.             prtseg(&seg1,"Results obtained");
  158.             prtseg(&expected[i],"Results expected");
  159.             cmpseg(&seg1,&expected[i]);
  160.         }
  161.  
  162.         i++;
  163.  
  164.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0);
  165.     
  166.     if(retval < 0)
  167.     {
  168.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  169.         return(-1);
  170.     }
  171.     if(PINT_REQUEST_DONE(rs1))
  172.     {
  173.         printf("**** request done.\n");
  174.     }
  175.  
  176.     return 0;
  177. }
  178.