Skip to content

Commit

Permalink
Bugfix/2017 04 bgq fixes (#152)
Browse files Browse the repository at this point in the history
* fixed typo with endianness test
* fixed type issues that appeared on bgq related to chars
* fixed typo in uberenv variant logic
* used signed char for bb64 decode table

on bgq, "char" defaults to an unsigned type with
gcc and xlc.

libb64 uses negative entries in its decoding table,
and the negative literals were being (silently) converted
to unsigned types, which broke the decoding logic.

* added more checks to bb64 smoke

Thanks to Kenny Weiss for the help tracking down
 and resolving these issues!
  • Loading branch information
cyrush committed Apr 3, 2017
1 parent 1077b0e commit cc64086
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scripts/uberenv/packages/uberenv-conduit/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def install(self, spec, prefix):
cfg.write("# sphinx from uberenv\n")
cfg.write("#" + cmake_cache_entry("SPHINX_EXECUTABLE",py3_sphinx_build_exe))

if not "+python" in spec or "+pyhton3" in spec:
if not "+python" in spec and "+python3" in spec:

This comment has been minimized.

Copy link
@kennyweiss

kennyweiss Apr 5, 2017

Member

This should be

if not "+python" in spec and not "+python3" in spec:

right?

This comment has been minimized.

Copy link
@cyrush

cyrush Apr 5, 2017

Author Member

gah!

cfg.write(cmake_cache_entry("ENABLE_PYTHON","OFF"))

#######################
Expand Down
2 changes: 1 addition & 1 deletion src/tests/conduit/c/t_c_conduit_node_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ TEST(c_conduit_node_set, set_native_int_ptr)
// set(...) semantics imply a copy -- mem addys should differ
EXPECT_NE(&icav_ptr[i],&icav[i]);
}
EXPECT_EQ(icav_ptr[5],-64);
EXPECT_EQ(icav_ptr[5],char(-64));

// using short* interface
conduit_node_set_short_ptr(n,isav,6);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/conduit/t_conduit_endianness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ TEST(conduit_endianness, node_swap_using_explicit_funcs)
8, // elem_bytes
Endianness::LITTLE_ID); // set not match

n["test32"].endian_swap_to_machine_default();
n["test64"].endian_swap_to_machine_default();
EXPECT_EQ(0x0102030405060708,test64.vuint64);

// swap all back back so we can do a full test on n
Expand Down
2 changes: 1 addition & 1 deletion src/tests/conduit/t_conduit_node_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,7 @@ TEST(conduit_node_set, set_cstyle_int_array)
// set(...) semantics imply a copy -- mem addys should differ
EXPECT_NE(&char_ptr[i],&char_av[i]);
}
EXPECT_EQ(char_ptr[5],-64);
EXPECT_EQ(char_ptr[5],char(-64));

// short
n.set(short_av_a);
Expand Down
30 changes: 27 additions & 3 deletions src/tests/thirdparty/t_libb64_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@
#include "b64/encode.h"
#include "b64/decode.h"

TEST(libb64_smoke, basic_use )

std::string
encode_decode(const std::string &val)
{
std::string sin("test");
std::string sin(val);

std::istringstream iss(sin);
std::ostringstream oss;
Expand All @@ -77,6 +79,28 @@ TEST(libb64_smoke, basic_use )

d.decode(iss,oss);

EXPECT_EQ(oss.str(),sin);
return oss.str();
}


TEST(libb64_smoke, basic_use )
{
std::string t = "test";
EXPECT_EQ(encode_decode(t),t);

// test a shorter string ...
t = "t";
EXPECT_EQ(encode_decode(t),t);

// test an empty string
t = "";
EXPECT_EQ(encode_decode(t),t);

t = "test a longer string";
EXPECT_EQ(encode_decode(t),t);

t = "test an even longer string with more vowels.";
EXPECT_EQ(encode_decode(t),t);

}

7 changes: 4 additions & 3 deletions src/thirdparty_builtin/libb64-1.2.1/src/cdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ MOD FOR CONDUIT: This warning suppression deals with issue w/ gcc on BG/Q.


#include <b64/cdecode.h>
#include <stdio.h>

int base64_decode_value(char value_in)
{
static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
static const signed char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
static const char decoding_size = sizeof(decoding);
value_in -= 43;
if (value_in < 0 || value_in >= decoding_size) return -1;
Expand All @@ -35,7 +36,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{
const char* codechar = code_in;
char* plainchar = plaintext_out;
char fragment;
signed char fragment;

*plainchar = state_in->plainchar;

Expand Down Expand Up @@ -89,7 +90,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{
state_in->step = step_d;
state_in->plainchar = 0;
return(int)(plainchar - plaintext_out);
return (int)(plainchar - plaintext_out);
}
fragment = (char)base64_decode_value(*codechar++);
} while (fragment < 0);
Expand Down

0 comments on commit cc64086

Please sign in to comment.