#!/bin/csh -f
#
# udrealcheck - check the udtrace for sensibleness
#   	ONLY for REAL_DATA
#
# usage:
#   dmcache ... |& udrealcheck
# with UD_TRACE turned on
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 3.0
#                              October 1996
#                          dfk@cs.dartmouth.edu

if ($#argv != 0) then
    echo usage: 'dmcache ... |& udrealcheck
    exit 1
endif

# The columns are:
#  1 "udtrace"
#  2 proc
#  3 time
#  4 copybytes
#  5 costbytes
#  6 where

# print the lines that are not quite right; "right lines" have 
#      both copybytes and costbytes 0
# or   copybytes == costbytes
# or   copybytes-costbytes == 4
# or   costbytes == 0 and noncyc_WordCopy
awk '($1 == "udtrace") { \
    if ($5 == 0 && $4 == 0) next; \
#    if ($4 == $5) next; \
    if ($4-$5 == 4) next; \
    if ($5 == 0 && $6 == "noncyc_WordCopy") next; \
    print; \
}'
