Skip to content

Commit

Permalink
New version now passes unit tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiker committed May 28, 2024
1 parent 1b4934b commit 9b04081
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 23 deletions.
30 changes: 18 additions & 12 deletions buildfiles/Windows.mak
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,52 @@ SD=das2
BD=build.windows

SRCS=$(SD)\das1.c $(SD)\array.c $(SD)\buffer.c $(SD)\builder.c $(SD)\cli.c \
$(SD)\credentials.c $(SD)\dataset.c $(SD)\datum.c $(SD)\descriptor.c \
$(SD)\codec.c $(SD)\credentials.c $(SD)\dataset.c $(SD)\datum.c $(SD)\descriptor.c \
$(SD)\dft.c $(SD)\dimension.c $(SD)\dsdf.c $(SD)\encoding.c $(SD)\frame.c \
$(SD)\http.c $(SD)\io.c $(SD)\json.c $(SD)\log.c $(SD)\node.c $(SD)\oob.c \
$(SD)\operator.c $(SD)\packet.c $(SD)\plane.c $(SD)\processor.c $(SD)\property.c \
$(SD)\send.c $(SD)\stream.c $(SD)\time.c $(SD)\tt2000.c $(SD)\units.c \
$(SD)\utf8.c $(SD)\util.c $(SD)\value.c $(SD)\variable.c
$(SD)\send.c $(SD)\serial.c $(SD)\stream.c $(SD)\time.c $(SD)\tt2000.c \
$(SD)\units.c $(SD)\utf8.c $(SD)\util.c $(SD)\value.c $(SD)\variable.c \
$(SD)\vector.c


LD=$(BD)\static
STATIC_OBJS=$(LD)\das1.obj $(LD)\array.obj $(LD)\buffer.obj $(LD)\builder.obj \
$(LD)\cli.obj $(LD)\credentials.obj $(LD)\dataset.obj $(LD)\datum.obj \
$(LD)\cli.obj $(LD)\codec.obj $(LD)\credentials.obj $(LD)\dataset.obj $(LD)\datum.obj \
$(LD)\descriptor.obj $(LD)\dft.obj $(LD)\dimension.obj $(LD)\dsdf.obj \
$(LD)\encoding.obj $(LD)\frame.obj $(LD)\http.obj $(LD)\io.obj $(LD)\json.obj \
$(LD)\log.obj $(LD)\node.obj $(LD)\oob.obj $(LD)\operator.obj $(LD)\packet.obj \
$(LD)\plane.obj $(LD)\processor.obj $(LD)\property.obj $(LD)\send.obj \
$(LD)\stream.obj $(LD)\time.obj $(LD)\tt2000.obj $(LD)\units.obj \
$(LD)\utf8.obj $(LD)\util.obj $(LD)\value.obj $(LD)\variable.obj
$(LD)\serial.obj $(LD)\stream.obj $(LD)\time.obj $(LD)\tt2000.obj \
$(LD)\units.obj $(LD)\utf8.obj $(LD)\util.obj $(LD)\value.obj \
$(LD)\variable.obj $(LD)\vector.obj

DD=$(BD)\shared
DLL_OBJS=$(DD)\das1.obj $(DD)\array.obj $(DD)\buffer.obj $(DD)\builder.obj \
$(DD)\cli.obj $(DD)\credentials.obj $(DD)\dataset.obj $(DD)\datum.obj \
$(DD)\cli.obj $(DD)\codec.obj $(DD)\credentials.obj $(DD)\dataset.obj $(DD)\datum.obj \
$(DD)\descriptor.obj $(DD)\dft.obj $(DD)\dimension.obj $(DD)\dsdf.obj \
$(DD)\encoding.obj $(DD)\frame.obj $(DD)\http.obj $(DD)\io.obj $(DD)\json.obj \
$(DD)\log.obj $(DD)\node.obj $(DD)\oob.obj $(DD)\operator.obj $(DD)\packet.obj \
$(DD)\plane.obj $(DD)\processor.obj $(DD)\property.obj $(DD)\send.obj \
$(DD)\stream.obj $(DD)\time.obj $(DD)\tt2000.obj $(DD)\units.obj \
$(DD)\utf8.obj $(DD)\util.obj $(DD)\value.obj $(DD)\variable.obj
$(DD)\serial.obj $(DD)\stream.obj $(DD)\time.obj $(DD)\tt2000.obj \
$(DD)\units.obj $(DD)\utf8.obj $(DD)\util.obj $(DD)\value.obj \
$(DD)\variable.obj $(DD)\vector.obj

HDRS=$(SD)\das1.h $(SD)\array.h $(SD)\buffer.h $(SD)\builder.h $(SD)\core.h \
$(SD)\cli.h $(SD)\credentials.h $(SD)\dataset.h $(SD)\datum.h $(SD)\descriptor.h \
$(SD)\codec.h $(SD)\cli.h $(SD)\credentials.h $(SD)\dataset.h $(SD)\datum.h $(SD)\descriptor.h \
$(SD)\defs.h $(SD)\dft.h $(SD)\dimension.h $(SD)\dsdf.h $(SD)\encoding.h \
$(SD)\frame.h $(SD)\http.h $(SD)\io.h $(SD)\json.h $(SD)\log.h $(SD)\node.h \
$(SD)\oob.h $(SD)\operator.h $(SD)\packet.h $(SD)\plane.h $(SD)\processor.h \
$(SD)\property.h $(SD)\send.h $(SD)\stream.h $(SD)\time.h $(SD)\tt2000.h \
$(SD)\units.h $(SD)\utf8.h $(SD)\util.h $(SD)\value.h $(SD)\variable.h
$(SD)\units.h $(SD)\utf8.h $(SD)\util.h $(SD)\value.h $(SD)\variable.h \
$(SD)\vector.h

UTIL_PROGS=$(BD)\das1_inctime.exe $(BD)\das2_prtime.exe $(BD)\das1_fxtime.exe \
$(BD)\das2_ascii.exe $(BD)\das2_bin_avg.exe $(BD)\das2_bin_avgsec.exe \
$(BD)\das2_bin_peakavgsec.exe $(BD)\das2_cache_rdr.exe $(BD)\das2_from_das1.exe \
$(BD)\das2_from_tagged_das1.exe $(BD)\das1_ascii.exe $(BD)\das1_bin_avg.exe \
$(BD)\das2_bin_ratesec.exe $(BD)\das2_psd.exe $(BD)\das2_hapi.exe \
$(BD)\das2_histo.exe $(BD)\das_node.exe
$(BD)\das2_histo.exe $(BD)\das3_node.exe

TEST_PROGS=$(BD)\TestUnits.exe $(BD)\TestArray.exe $(BD)\LoadStream.exe \
$(BD)\TestBuilder.exe $(BD)\TestAuth.exe $(BD)\TestCatalog.exe $(BD)\TestTT2000.exe \
Expand Down Expand Up @@ -111,6 +115,7 @@ run_test:
$(BD)\TestBuilder.exe
$(BD)\LoadStream.exe
$(BD)\TestCredMngr.exe $(BD)
$(BD)\TestV3Read.exe

run_test_spice: run_test
$(BD)\TestSpice.exe
Expand Down Expand Up @@ -174,4 +179,5 @@ clean:

distclean:
if exist $(BD) rmdir /S /Q $(BD)
del *.obj

8 changes: 4 additions & 4 deletions das2/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,8 @@ int _DasIO_dataTypeOrErr(DasIO* pThis, DasBuf* pBuf, bool bFirstRead, int* pPktI
switch(sTag[0]){
case '<':
// Save the first 4 bytes in pPktId so that they don't evaporate
uPack = ( (ubyte)sTag[0] )|( ((ubyte)sTag[1]) >> 8 )|( ((ubyte)sTag[2]) >> 16 )|
( ((ubyte)sTag[3]) >> 24 );
uPack = ( (uint32_t)(ubyte)sTag[0] )|( ((uint32_t)(ubyte)sTag[1]) >> 8 )|
( ((uint32_t)(ubyte)sTag[2]) >> 16 )|( ((uint32_t)(ubyte)sTag[3]) >> 24 );
*pPktId = *((int*)(&uPack));
if(bFirstRead)
return (IO_CHUNK_DOC | IO_ENC_XML);
Expand All @@ -926,8 +926,8 @@ int _DasIO_dataTypeOrErr(DasIO* pThis, DasBuf* pBuf, bool bFirstRead, int* pPktI

case '{':
// Save the first 4 bytes in pPktId so that they don't evaporate
uPack = ( (ubyte)sTag[0] )|( ((ubyte)sTag[1]) >> 8 )|( ((ubyte)sTag[2]) >> 16 )|
( ((ubyte)sTag[3]) >> 24 );
uPack = ( (uint32_t)(ubyte)sTag[0] )|( ((uint32_t)(ubyte)sTag[1]) >> 8 )|
( ((uint32_t)(ubyte)sTag[2]) >> 16 )|( ((uint32_t)(ubyte)sTag[3]) >> 24 );
*pPktId = *((int*)(&uPack));

if(bFirstRead)
Expand Down
6 changes: 5 additions & 1 deletion das2/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,11 @@ int DasProp_items(const DasProp* pProp)
*/
int DasProp_convertInt(const DasProp* pProp, int64_t* pBuf, size_t uBufLen)
{
if(sscanf(DasProp_value(pProp), "%ld", pBuf) != 1)
#ifdef _WIN32
if(sscanf(DasProp_value(pProp), "%lld", pBuf) != 1)
#else
if(sscanf(DasProp_value(pProp), "%ld", pBuf) != 1)
#endif
return -1 * das_error(DASERR_PROP, "Error converting '%s' to a double",
DasProp_value(pProp)
);
Expand Down
6 changes: 3 additions & 3 deletions das2/units.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,8 +1610,8 @@ double Units_convertTo(das_units to, double rFrom, das_units from)
#define DAYS_PER_100Y (365*100 + 24)
#define DAYS_PER_4Y (365*4 + 1)

#define DAS_INT32_MIN -2147483648
#define DAS_INT32_MAX 2147483647
#define DAS_INT32_MIN -2147483648LL
#define DAS_INT32_MAX 2147483647LL

DasErrCode unixToCalDate(das_time* pDt, int64_t nUnix)
{
Expand All @@ -1623,7 +1623,7 @@ DasErrCode unixToCalDate(das_time* pDt, int64_t nUnix)
static const char days_in_month[] = {31,30,31,30,31,31,30,31,30,31,31,29};

/* Reject time_t values whose year would overflow int32 */
if (nUnix < DAS_INT32_MIN * 31622400LL || nUnix > DAS_INT32_MAX * 31622400LL){
if ((nUnix < (DAS_INT32_MIN * 31622400LL)) || (nUnix > (DAS_INT32_MAX * 31622400LL))){
return das_error(DASERR_UNITS, "Unix time value %lld would overflow during conversion", nUnix);
}

Expand Down
16 changes: 14 additions & 2 deletions das2/value.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,25 @@ DasErrCode das_value_fromStr(
return sscanf(sStr, "%d", (int32_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
case vtULong:
#ifdef HOST_IS_64_BIT
return sscanf(sStr, "%lu", (uint64_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
return sscanf(sStr,
#ifdef _WIN32
"%llu"
#else
"%lu"
#endif
, (uint64_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
#else
return sscanf(sStr, "%Lu", (uint64_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
#endif
case vtLong:
#ifdef HOST_IS_64_BIT
return sscanf(sStr, "%ld", (int64_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
return sscanf(sStr,
#ifdef _WIN32
"%lld"
#else
"%ld"
#endif
, (int64_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
#else
return sscanf(sStr, "%Ld", (int64_t*)pBuf) == 1 ? DAS_OKAY : DASERR_VALUE;
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/TestUnits.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int main(int argc, char** argv) {
}

/* Test ns1970 conversions (used by numpy) */
long nTime = 1451606400000000000LL; /* 2016-01-01 */
int64_t nTime = 1451606400000000000LL; /* 2016-01-01 */
rTime = (double)nTime;
dt_null(&dt1);
units = Units_fromStr("ns1970");
Expand Down

0 comments on commit 9b04081

Please sign in to comment.